diff options
author | Bin Cheng <bin.cheng@arm.com> | 2017-08-24 15:38:39 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2017-08-24 15:38:39 +0000 |
commit | 142ff60219724cac948be5bef9fc4e6d1bfb8cfb (patch) | |
tree | c4b28372b10080cb931f0905dce292ad29c904fd /gcc/tree-ssa-loop-niter.c | |
parent | 14e18d7100de30f3c2991401bbb414d2e3ffb716 (diff) | |
download | gcc-142ff60219724cac948be5bef9fc4e6d1bfb8cfb.zip gcc-142ff60219724cac948be5bef9fc4e6d1bfb8cfb.tar.gz gcc-142ff60219724cac948be5bef9fc4e6d1bfb8cfb.tar.bz2 |
re PR tree-optimization/81913 (wrong code at -O1)
PR tree-optimization/81913
* tree-ssa-loop-niter.c (number_of_iterations_cond): Skip niter
analysis when either IVs in condition can wrap.
gcc/testsuite
* gcc.c-torture/execute/pr81913.c: New test.
* gcc.dg/tree-ssa/loop-niter-1.c: New test.
* gcc.dg/tree-ssa/loop-niter-2.c: New test.
From-SVN: r251337
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 0d6d101..27244eb 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1728,7 +1728,7 @@ number_of_iterations_cond (struct loop *loop, provided that either below condition is satisfied: a) the test is NE_EXPR; - b) iv0.step - iv1.step is positive integer. + b) iv0.step - iv1.step is integer and iv0/iv1 don't overflow. This rarely occurs in practice, but it is simple enough to manage. */ if (!integer_zerop (iv0->step) && !integer_zerop (iv1->step)) @@ -1739,7 +1739,9 @@ number_of_iterations_cond (struct loop *loop, /* No need to check sign of the new step since below code takes care of this well. */ - if (code != NE_EXPR && TREE_CODE (step) != INTEGER_CST) + if (code != NE_EXPR + && (TREE_CODE (step) != INTEGER_CST + || !iv0->no_overflow || !iv1->no_overflow)) return false; iv0->step = step; |