+2008-03-02 Sebastian Pop <sebastian.pop@amd.com>
+
+ * tree-scalar-evolution.c (instantiate_parameters_1): An SSA_NAME
+ defined in a loop at depth 0 is invariant.
+ * tree-chrec.c (evolution_function_is_invariant_rec_p): Ditto.
+ * tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Should never
+ be called at loop depth 0.
+
2008-03-02 Jakub Jelinek <jakub@redhat.com>
PR driver/35420
if (evolution_function_is_constant_p (chrec))
return true;
- if (TREE_CODE (chrec) == SSA_NAME
- && expr_invariant_in_loop_p (get_loop (loopnum), chrec))
+ if (TREE_CODE (chrec) == SSA_NAME
+ && (loopnum == 0
+ || expr_invariant_in_loop_p (get_loop (loopnum), chrec)))
return true;
if (TREE_CODE (chrec) == POLYNOMIAL_CHREC)
/* A parameter (or loop invariant and we do not want to include
evolutions in outer loops), nothing to do. */
if (!def_bb
+ || loop_depth (def_bb->loop_father) == 0
|| (!(flags & INSERT_SUPERLOOP_CHRECS)
&& !flow_bb_inside_loop_p (loop, def_bb)))
return chrec;
}
/* Returns true if expression EXPR is obviously invariant in LOOP,
- i.e. if all its operands are defined outside of the LOOP. */
+ i.e. if all its operands are defined outside of the LOOP. LOOP
+ should not be the function body. */
bool
expr_invariant_in_loop_p (struct loop *loop, tree expr)
basic_block def_bb;
unsigned i, len;
+ gcc_assert (loop_depth (loop) > 0);
+
if (is_gimple_min_invariant (expr))
return true;