get_loop_exit_condition (struct loop *loop)
{
tree res = NULL_TREE;
- edge exit_edge = loop->single_exit;
-
+ edge exit_edge = single_exit (loop);
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "(get_loop_exit_condition \n ");
get_exit_conditions_rec (loop->inner, exit_conditions);
get_exit_conditions_rec (loop->next, exit_conditions);
- if (loop->single_exit)
+ if (single_exit (loop))
{
tree loop_condition = get_loop_exit_condition (loop);
initializes the EXIT_CONDITIONS array. */
static void
-select_loops_exit_conditions (struct loops *loops,
- VEC(tree,heap) **exit_conditions)
+select_loops_exit_conditions (VEC(tree,heap) **exit_conditions)
{
- struct loop *function_body = loops->parray[0];
+ struct loop *function_body = current_loops->tree_root;
get_exit_conditions_rec (function_body->inner, exit_conditions);
}
/* EXPR is a scalar evolution of a pointer that is dereferenced or used in
comparison. This means that it must point to a part of some object in
memory, which enables us to argue about overflows and possibly simplify
- the EXPR. Returns the simplified value.
+ the EXPR. AT_STMT is the statement in which this conversion has to be
+ performed. Returns the simplified value.
Currently, for
bugs. */
static tree
-fold_used_pointer (tree expr)
+fold_used_pointer (tree expr, tree at_stmt)
{
tree op0, op1, new0, new1;
enum tree_code code = TREE_CODE (expr);
if (pointer_offset_p (op1))
{
- new0 = fold_used_pointer (op0);
+ new0 = fold_used_pointer (op0, at_stmt);
new1 = fold_used_pointer_cast (op1);
}
else if (code == PLUS_EXPR && pointer_offset_p (op0))
{
new0 = fold_used_pointer_cast (op0);
- new1 = fold_used_pointer (op1);
+ new1 = fold_used_pointer (op1, at_stmt);
}
else
return expr;
if (new0 == op0 && new1 == op1)
return expr;
+ new0 = chrec_convert (TREE_TYPE (expr), new0, at_stmt);
+ new1 = chrec_convert (TREE_TYPE (expr), new1, at_stmt);
+
if (code == PLUS_EXPR)
expr = chrec_fold_plus (TREE_TYPE (expr), new0, new1);
else
if (POINTER_TYPE_P (type)
&& !automatically_generated_chrec_p (res)
&& pointer_used_p (var))
- res = fold_used_pointer (res);
+ res = fold_used_pointer (res, def);
break;
case PHI_NODE:
return NULL_TREE;
loop = loop_containing_stmt (SSA_NAME_DEF_STMT (var));
- exit = loop->single_exit;
+ exit = single_exit (loop);
if (!exit)
return NULL_TREE;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "(number_of_iterations_in_loop\n");
- exit = loop->single_exit;
+ exit = single_exit (loop);
if (!exit)
goto end;
/* Initialize the analysis of scalar evolutions for LOOPS. */
void
-scev_initialize (struct loops *loops)
+scev_initialize (void)
{
unsigned i;
- current_loops = loops;
scalar_evolution_info = htab_create (100, hash_scev_info,
eq_scev_info, del_scev_info);
initialize_scalar_evolutions_analyzer ();
- for (i = 1; i < loops->num; i++)
- if (loops->parray[i])
- loops->parray[i]->nb_iterations = NULL_TREE;
+ for (i = 1; i < current_loops->num; i++)
+ if (current_loops->parray[i])
+ current_loops->parray[i]->nb_iterations = NULL_TREE;
}
/* Cleans up the information cached by the scalar evolutions analysis. */
VEC(tree,heap) *exit_conditions;
exit_conditions = VEC_alloc (tree, heap, 37);
- select_loops_exit_conditions (current_loops, &exit_conditions);
+ select_loops_exit_conditions (&exit_conditions);
if (dump_file && (dump_flags & TDF_STATS))
analyze_scalar_evolution_for_all_loop_phi_nodes (&exit_conditions);
/* If we do not know exact number of iterations of the loop, we cannot
replace the final value. */
- exit = loop->single_exit;
+ exit = single_exit (loop);
if (!exit)
continue;