summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-03 07:57:13 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-03 07:57:13 +0000
commitdabc0f790ad143ab68f2c4a5436b8fd7c53e04b9 (patch)
tree1c1bfc05a918621344364216fc91756fa3382cc6
parentd2c73eb950e9643c4f928a53797e95321dee94a1 (diff)
downloadgcc-dabc0f790ad143ab68f2c4a5436b8fd7c53e04b9.tar.gz
2015-06-03 Richard Biener <rguenther@suse.de>
PR tree-optimization/66375 * tree-scalar-evolution.c (follow_ssa_edge_binary): First add to the evolution before following SSA edges. * gcc.dg/torture/pr66375.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224060 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr66375.c13
-rw-r--r--gcc/tree-scalar-evolution.c50
4 files changed, 48 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 07743bba32e..06dda145fd6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-03 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/66375
+ * tree-scalar-evolution.c (follow_ssa_edge_binary): First
+ add to the evolution before following SSA edges.
+
2015-06-03 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (dump_iv): New parameter.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3abe065e648..9fd5941e979 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-03 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/66375
+ * gcc.dg/torture/pr66375.c: New testcase.
+
2015-06-03 Bin Cheng <bin.cheng@arm.com>
* gcc.dg/tree-ssa/pr65447.c: Increase searching number.
diff --git a/gcc/testsuite/gcc.dg/torture/pr66375.c b/gcc/testsuite/gcc.dg/torture/pr66375.c
new file mode 100644
index 00000000000..2447b43c17b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr66375.c
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+
+int a;
+extern void abort (void);
+int main ()
+{
+ int c = 0;
+ for (; a < 13; ++a)
+ c = (signed char)c - 11;
+ if (c != 113)
+ abort ();
+ return 0;
+}
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 013fc507830..3a2c284b582 100644
--- a/gcc/tree-scalar-evolution.c
+++ b/gcc/tree-scalar-evolution.c
@@ -958,27 +958,25 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
limit++;
evol = *evolution_of_loop;
- res = follow_ssa_edge
- (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
-
- if (res == t_true)
- *evolution_of_loop = add_to_evolution
+ evol = add_to_evolution
(loop->num,
chrec_convert (type, evol, at_stmt),
code, rhs1, at_stmt);
-
+ res = follow_ssa_edge
+ (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
+ if (res == t_true)
+ *evolution_of_loop = evol;
else if (res == t_false)
{
+ *evolution_of_loop = add_to_evolution
+ (loop->num,
+ chrec_convert (type, *evolution_of_loop, at_stmt),
+ code, rhs0, at_stmt);
res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
evolution_of_loop, limit);
-
if (res == t_true)
- *evolution_of_loop = add_to_evolution
- (loop->num,
- chrec_convert (type, *evolution_of_loop, at_stmt),
- code, rhs0, at_stmt);
-
+ ;
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
}
@@ -991,15 +989,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
{
/* Match an assignment under the form:
"a = b + ...". */
+ *evolution_of_loop = add_to_evolution
+ (loop->num, chrec_convert (type, *evolution_of_loop,
+ at_stmt),
+ code, rhs1, at_stmt);
res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
evolution_of_loop, limit);
if (res == t_true)
- *evolution_of_loop = add_to_evolution
- (loop->num, chrec_convert (type, *evolution_of_loop,
- at_stmt),
- code, rhs1, at_stmt);
-
+ ;
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
}
@@ -1009,15 +1007,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
{
/* Match an assignment under the form:
"a = ... + c". */
+ *evolution_of_loop = add_to_evolution
+ (loop->num, chrec_convert (type, *evolution_of_loop,
+ at_stmt),
+ code, rhs0, at_stmt);
res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
evolution_of_loop, limit);
if (res == t_true)
- *evolution_of_loop = add_to_evolution
- (loop->num, chrec_convert (type, *evolution_of_loop,
- at_stmt),
- code, rhs0, at_stmt);
-
+ ;
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
}
@@ -1042,13 +1040,13 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
if (TREE_CODE (rhs1) == SSA_NAME)
limit++;
+ *evolution_of_loop = add_to_evolution
+ (loop->num, chrec_convert (type, *evolution_of_loop, at_stmt),
+ MINUS_EXPR, rhs1, at_stmt);
res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
evolution_of_loop, limit);
if (res == t_true)
- *evolution_of_loop = add_to_evolution
- (loop->num, chrec_convert (type, *evolution_of_loop, at_stmt),
- MINUS_EXPR, rhs1, at_stmt);
-
+ ;
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
}