diff options
author | amonakov <amonakov@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-17 12:54:59 +0000 |
---|---|---|
committer | amonakov <amonakov@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-17 12:54:59 +0000 |
commit | c7cee0e4c963137d279cdf7da90b2c4b30a81edc (patch) | |
tree | 82650d43c859500d7f4079f0ccb5f35a7bc07a1d /gcc/graphite-clast-to-gimple.c | |
parent | 9dff0fca2f7e39b849cc69770f924c2cebc8cbd6 (diff) | |
download | gcc-c7cee0e4c963137d279cdf7da90b2c4b30a81edc.tar.gz |
PR middle-end/46761
* graphite-clast-to-gimple.c (graphite_create_new_loop_guard): Prefer
to use unadjusted UB.
testsuite:
* gcc.dg/graphite/pr46761.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167980 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-clast-to-gimple.c')
-rw-r--r-- | gcc/graphite-clast-to-gimple.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index eef5ad16abd..0937fc8eb94 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -975,20 +975,24 @@ graphite_create_new_loop_guard (sese region, edge entry_edge, newivs_index, params_index); tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs, newivs_index, params_index); - tree one = POINTER_TYPE_P (type) ? size_one_node - : fold_convert (type, integer_one_node); - /* Adding +1 and using LT_EXPR helps with loop latches that have a - loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes - 2^{32|64}, and the condition lb <= ub is true, even if we do not want this. - However lb < ub + 1 is false, as expected. */ - tree ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR - : PLUS_EXPR, type, ub, one); - - /* When ub + 1 wraps around, use lb <= ub. */ - if (integer_zerop (ub_one)) + /* When ub is simply a constant or a parameter, use lb <= ub. */ + if (TREE_CODE (ub) == INTEGER_CST || TREE_CODE (ub) == SSA_NAME) cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub); else - cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one); + { + tree one = (POINTER_TYPE_P (type) + ? size_one_node + : fold_convert (type, integer_one_node)); + /* Adding +1 and using LT_EXPR helps with loop latches that have a + loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes + 2^k-1 due to integer overflow, and the condition lb <= ub is true, + even if we do not want this. However lb < ub + 1 is false, as + expected. */ + tree ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR + : PLUS_EXPR, type, ub, one); + + cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one); + } exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr); |