diff options
author | Sebastian Pop <sebastian.pop@amd.com> | 2009-10-21 23:05:39 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2009-10-21 23:05:39 +0000 |
commit | f29deac9bd4ae965809d7735631f707e38b40f82 (patch) | |
tree | 19f73c5acca1dc29d3476bc353efe3c387d3dae3 /gcc/tree-scalar-evolution.c | |
parent | f4e1881041d1458b50cba9e892ed94c483ea64ec (diff) | |
download | gcc-f29deac9bd4ae965809d7735631f707e38b40f82.zip gcc-f29deac9bd4ae965809d7735631f707e38b40f82.tar.gz gcc-f29deac9bd4ae965809d7735631f707e38b40f82.tar.bz2 |
re PR tree-optimization/41497 (apparent integer wrong code bug)
PR tree-optimization/41497
* tree-scalar-evolution.c (analyze_evolution_in_loop): Return
chrec_dont_know if the evolution function returned by follow_ssa_edge
is constant in the analyzed loop and is not compatible with the
initial value before the loop.
* tree-chrec.h (no_evolution_in_loop_p): Call STRIP_NOPS.
* gcc.dg/tree-ssa/pr41497.c: New.
From-SVN: r153441
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 02a4eed..70af0fd 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1492,18 +1492,29 @@ analyze_evolution_in_loop (gimple loop_phi_node, bb = gimple_phi_arg_edge (loop_phi_node, i)->src; if (!flow_bb_inside_loop_p (loop, bb)) continue; - + if (TREE_CODE (arg) == SSA_NAME) { + bool val = false; + ssa_chain = SSA_NAME_DEF_STMT (arg); /* Pass in the initial condition to the follow edge function. */ ev_fn = init_cond; res = follow_ssa_edge (loop, ssa_chain, loop_phi_node, &ev_fn, 0); + + /* If ev_fn has no evolution in the inner loop, and the + init_cond is not equal to ev_fn, then we have an + ambiguity between two possible values, as we cannot know + the number of iterations at this point. */ + if (TREE_CODE (ev_fn) != POLYNOMIAL_CHREC + && no_evolution_in_loop_p (ev_fn, loop->num, &val) && val + && !operand_equal_p (init_cond, ev_fn, 0)) + ev_fn = chrec_dont_know; } else res = t_false; - + /* When it is impossible to go back on the same loop_phi_node by following the ssa edges, the evolution is represented by a peeled chrec, i.e. the |