halting_phi, evolution_of_loop, limit);
break;
+ case ADDR_EXPR:
+ /* Handle &MEM[ptr + CST] which is equivalent to POINTER_PLUS_EXPR. */
+ if (TREE_CODE (TREE_OPERAND (expr, 0)) == MEM_REF)
+ {
+ expr = TREE_OPERAND (expr, 0);
+ rhs0 = TREE_OPERAND (expr, 0);
+ rhs1 = TREE_OPERAND (expr, 1);
+ type = TREE_TYPE (rhs0);
+ STRIP_USELESS_TYPE_CONVERSION (rhs0);
+ STRIP_USELESS_TYPE_CONVERSION (rhs1);
+ res = follow_ssa_edge_binary (loop, at_stmt, type,
+ rhs0, POINTER_PLUS_EXPR, rhs1,
+ halting_phi, evolution_of_loop, limit);
+ }
+ else
+ res = t_false;
+ break;
+
case ASSERT_EXPR:
/* This assignment is of the form: "a_1 = ASSERT_EXPR <a_2, ...>"
It must be handled as a copy assignment of the form a_1 = a_2. */
result again. */
res = analyze_scalar_evolution (def_loop, chrec);
- /* Don't instantiate loop-closed-ssa phi nodes. */
+ /* Don't instantiate default definitions. */
if (TREE_CODE (res) == SSA_NAME
- && (loop_containing_stmt (SSA_NAME_DEF_STMT (res)) == NULL
- || (loop_depth (loop_containing_stmt (SSA_NAME_DEF_STMT (res)))
- > loop_depth (def_loop))))
+ && SSA_NAME_IS_DEFAULT_DEF (res))
+ ;
+
+ /* Don't instantiate loop-closed-ssa phi nodes. */
+ else if (TREE_CODE (res) == SSA_NAME
+ && loop_depth (loop_containing_stmt (SSA_NAME_DEF_STMT (res)))
+ > loop_depth (def_loop))
{
if (res == chrec)
res = loop_closed_phi_def (chrec);
else
res = chrec;
- if (res == NULL_TREE
- || !dominated_by_p (CDI_DOMINATORS, instantiate_below,
- gimple_bb (SSA_NAME_DEF_STMT (res))))
+ /* When there is no loop_closed_phi_def, it means that the
+ variable is not used after the loop: try to still compute the
+ value of the variable when exiting the loop. */
+ if (res == NULL_TREE)
+ {
+ loop_p loop = loop_containing_stmt (SSA_NAME_DEF_STMT (chrec));
+ res = analyze_scalar_evolution (loop, chrec);
+ res = compute_overall_effect_of_inner_loop (loop, res);
+ res = instantiate_scev_r (instantiate_below, evolution_loop, res,
+ fold_conversions, cache, size_expr);
+ }
+ else if (!dominated_by_p (CDI_DOMINATORS, instantiate_below,
+ gimple_bb (SSA_NAME_DEF_STMT (res))))
res = chrec_dont_know;
}
/* Store the correct value to the cache. */
set_instantiated_value (cache, instantiate_below, chrec, res);
return res;
-
}
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
unsigned nb_static_loops = 0;
gimple cond;
- for (i = 0; VEC_iterate (gimple, *exit_conditions, i, cond); i++)
+ FOR_EACH_VEC_ELT (gimple, *exit_conditions, i, cond)
{
tree res = number_of_latch_executions (loop_containing_stmt (cond));
if (chrec_contains_undetermined (res))
reset_chrecs_counters (&stats);
- for (i = 0; VEC_iterate (gimple, *exit_conditions, i, cond); i++)
+ FOR_EACH_VEC_ELT (gimple, *exit_conditions, i, cond)
{
struct loop *loop;
basic_block bb;