summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@arm.com>2016-08-09 15:08:02 +0000
committerBin Cheng <amker@gcc.gnu.org>2016-08-09 15:08:02 +0000
commit42970a179d71e59c317440d0567b003681e915ba (patch)
treee2dec7e06bcb0dea52cd1cba64b1dc05f6b884da /gcc/tree-ssa-loop-niter.c
parent8aa46dd2d5808a951afee6c6322615225f298d6a (diff)
re PR tree-optimization/72772 (Missed SCEV after pass reordering@236440)
PR tree-optimization/72772 * tree-ssa-loop-niter.c (loop_exits_before_overflow): Check equality for expanded base. gcc/testsuite PR tree-optimization/pr72772 * gcc.dg/tree-ssa/pr72772.c: New test. From-SVN: r239291
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index a34672afd24..a50d2b4b43e 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -4214,7 +4214,7 @@ loop_exits_before_overflow (tree base, tree step,
for (civ = loop->control_ivs; civ; civ = civ->next)
{
enum tree_code code;
- tree stepped, extreme, civ_type = TREE_TYPE (civ->step);
+ tree civ_type = TREE_TYPE (civ->step);
/* Have to consider type difference because operand_equal_p ignores
that for constants. */
@@ -4227,11 +4227,13 @@ loop_exits_before_overflow (tree base, tree step,
continue;
/* Done proving if this is a no-overflow control IV. */
- if (operand_equal_p (base, civ->base, 0)
- /* Control IV is recorded after expanding simple operations,
- Here we compare it against expanded base too. */
- || operand_equal_p (expand_simple_operations (base),
- civ->base, 0))
+ if (operand_equal_p (base, civ->base, 0))
+ return true;
+
+ /* Control IV is recorded after expanding simple operations,
+ Here we expand base and compare it too. */
+ tree expanded_base = expand_simple_operations (base);
+ if (operand_equal_p (expanded_base, civ->base, 0))
return true;
/* If this is a before stepping control IV, in other words, we have
@@ -4253,9 +4255,14 @@ loop_exits_before_overflow (tree base, tree step,
else
code = PLUS_EXPR;
- stepped = fold_build2 (code, TREE_TYPE (base), base, step);
- if (operand_equal_p (stepped, civ->base, 0))
+ tree stepped = fold_build2 (code, TREE_TYPE (base), base, step);
+ tree expanded_stepped = fold_build2 (code, TREE_TYPE (base),
+ expanded_base, step);
+ if (operand_equal_p (stepped, civ->base, 0)
+ || operand_equal_p (expanded_stepped, civ->base, 0))
{
+ tree extreme;
+
if (tree_int_cst_sign_bit (step))
{
code = LT_EXPR;