summaryrefslogtreecommitdiff
path: root/gcc/tree-scalar-evolution.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2009-10-21 23:05:39 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2009-10-21 23:05:39 +0000
commit8da11536673aba7617a056943f17b857808c32de (patch)
tree19f73c5acca1dc29d3476bc353efe3c387d3dae3 /gcc/tree-scalar-evolution.c
parent8d057f8c0150a739ccf6fd8a8ce21fba794efa1b (diff)
downloadgcc-8da11536673aba7617a056943f17b857808c32de.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153441 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r--gcc/tree-scalar-evolution.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c
index 02a4eed646e..70af0fda610 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