aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
authorSebastian Pop <pop@cri.ensmp.fr>2005-09-01 17:09:41 +0200
committerSebastian Pop <spop@gcc.gnu.org>2005-09-01 15:09:41 +0000
commitab02cc4e2c9ed04b6ebce7d923794ebcec8f384f (patch)
tree6d4d09788e3e10097c2ae3a66de156d01ebe655b /gcc/tree-ssa-loop-niter.c
parentac156e917633afc778914af2a5e605678767fdba (diff)
downloadgcc-ab02cc4e2c9ed04b6ebce7d923794ebcec8f384f.zip
gcc-ab02cc4e2c9ed04b6ebce7d923794ebcec8f384f.tar.gz
gcc-ab02cc4e2c9ed04b6ebce7d923794ebcec8f384f.tar.bz2
re PR middle-end/23410 (FAIL: gcc.c-torture/execute/950612-1.c execution, at -Os and -O3)
PR tree-optimization/23410 * tree-ssa-loop-niter.c (scev_probably_wraps_p): Check that the sequence is not wrapping during the first step. From-SVN: r103733
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index 5ecdaeb..3ee27f4 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -1823,7 +1823,8 @@ scev_probably_wraps_p (tree type, tree base, tree step,
struct nb_iter_bound *bound;
tree delta, step_abs;
tree unsigned_type, valid_niter;
- tree base_plus_step;
+ tree base_plus_step, bpsps;
+ int cps, cpsps;
/* FIXME: The following code will not be used anymore once
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg02025.html is
@@ -1865,7 +1866,17 @@ scev_probably_wraps_p (tree type, tree base, tree step,
*unknown_max = false;
base_plus_step = fold_build2 (PLUS_EXPR, type, base, step);
- switch (compare_trees (base_plus_step, base))
+ bpsps = fold_build2 (PLUS_EXPR, type, base_plus_step, step);
+ cps = compare_trees (base_plus_step, base);
+ cpsps = compare_trees (bpsps, base_plus_step);
+
+ /* Check that the sequence is not wrapping in the first step: it
+ should have the same monotonicity for the first two steps. See
+ PR23410. */
+ if (cps != cpsps)
+ return true;
+
+ switch (cps)
{
case -1:
{