Commit b9b79ba4 by Richard Biener Committed by Richard Biener

re PR middle-end/66375 (wrong code at -O2 and -O3 on x86_64-linux-gnu)

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.

From-SVN: r224060
parent e185f450
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> 2015-06-03 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (dump_iv): New parameter. * tree-ssa-loop-ivopts.c (dump_iv): New parameter.
......
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> 2015-06-03 Bin Cheng <bin.cheng@arm.com>
* gcc.dg/tree-ssa/pr65447.c: Increase searching number. * gcc.dg/tree-ssa/pr65447.c: Increase searching number.
......
/* { 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;
}
...@@ -958,27 +958,25 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt, ...@@ -958,27 +958,25 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
limit++; limit++;
evol = *evolution_of_loop; evol = *evolution_of_loop;
res = follow_ssa_edge evol = add_to_evolution
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
if (res == t_true)
*evolution_of_loop = add_to_evolution
(loop->num, (loop->num,
chrec_convert (type, evol, at_stmt), chrec_convert (type, evol, at_stmt),
code, rhs1, 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) 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 res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi, (loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
evolution_of_loop, limit); evolution_of_loop, limit);
if (res == t_true) 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) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
} }
...@@ -991,15 +989,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt, ...@@ -991,15 +989,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
{ {
/* Match an assignment under the form: /* Match an assignment under the form:
"a = b + ...". */ "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 res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
evolution_of_loop, limit); evolution_of_loop, limit);
if (res == t_true) 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) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
} }
...@@ -1009,15 +1007,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt, ...@@ -1009,15 +1007,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
{ {
/* Match an assignment under the form: /* Match an assignment under the form:
"a = ... + c". */ "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 res = follow_ssa_edge
(loop, SSA_NAME_DEF_STMT (rhs1), halting_phi, (loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
evolution_of_loop, limit); evolution_of_loop, limit);
if (res == t_true) 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) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
} }
...@@ -1042,13 +1040,13 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt, ...@@ -1042,13 +1040,13 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
if (TREE_CODE (rhs1) == SSA_NAME) if (TREE_CODE (rhs1) == SSA_NAME)
limit++; 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, res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
evolution_of_loop, limit); evolution_of_loop, limit);
if (res == t_true) 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) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment