diff options
author | Sebastian Pop <pop@cri.ensmp.fr> | 2005-08-15 09:51:42 +0200 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2005-08-15 07:51:42 +0000 |
commit | 852c19aae40795aff2dabaee47422e65f99b116a (patch) | |
tree | 5b3c0b02617e1703f136627dfce53def821570d2 /gcc/tree-data-ref.c | |
parent | 309b0e4232a331e7293d6086cef1573201a10507 (diff) | |
download | gcc-852c19aae40795aff2dabaee47422e65f99b116a.zip gcc-852c19aae40795aff2dabaee47422e65f99b116a.tar.gz gcc-852c19aae40795aff2dabaee47422e65f99b116a.tar.bz2 |
re PR tree-optimization/23386 (bitmap.c is being miscompiled (VRP))
PR 23386
* tree-data-ref.c (estimate_niter_from_size_of_data): When
step is negative compute the estimation from init downwards to
zero.
* testsuite/gcc.dg/tree-ssa/pr23386.c: New.
From-SVN: r103106
Diffstat (limited to 'gcc/tree-data-ref.c')
-rw-r--r-- | gcc/tree-data-ref.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 24856ed..1848128 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -751,7 +751,7 @@ estimate_niter_from_size_of_data (struct loop *loop, tree access_fn, tree stmt) { - tree estimation; + tree estimation = NULL_TREE; tree array_size, data_size, element_size; tree init, step; @@ -773,11 +773,28 @@ estimate_niter_from_size_of_data (struct loop *loop, && TREE_CODE (init) == INTEGER_CST && TREE_CODE (step) == INTEGER_CST) { - estimation = fold_build2 (CEIL_DIV_EXPR, integer_type_node, - fold_build2 (MINUS_EXPR, integer_type_node, - data_size, init), step); - - record_estimate (loop, estimation, boolean_true_node, stmt); + tree i_plus_s = fold_build2 (PLUS_EXPR, integer_type_node, init, step); + tree sign = fold_build2 (GT_EXPR, boolean_type_node, i_plus_s, init); + + if (sign == boolean_true_node) + estimation = fold_build2 (CEIL_DIV_EXPR, integer_type_node, + fold_build2 (MINUS_EXPR, integer_type_node, + data_size, init), step); + + /* When the step is negative, as in PR23386: (init = 3, step = + 0ffffffff, data_size = 100), we have to compute the + estimation as ceil_div (init, 0 - step) + 1. */ + else if (sign == boolean_false_node) + estimation = + fold_build2 (PLUS_EXPR, integer_type_node, + fold_build2 (CEIL_DIV_EXPR, integer_type_node, + init, + fold_build2 (MINUS_EXPR, unsigned_type_node, + integer_zero_node, step)), + integer_one_node); + + if (estimation) + record_estimate (loop, estimation, boolean_true_node, stmt); } } |