aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-im.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-im.c')
-rw-r--r--gcc/tree-ssa-loop-im.c59
1 files changed, 21 insertions, 38 deletions
diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c
index 2fbaa62..503e662 100644
--- a/gcc/tree-ssa-loop-im.c
+++ b/gcc/tree-ssa-loop-im.c
@@ -86,7 +86,9 @@ struct lim_aux_data
unsigned cost; /* Cost of the computation performed by the
statement. */
- vec<gimple *> depends; /* Vector of statements that must be also
+ unsigned ref; /* The simple_mem_ref in this stmt or 0. */
+
+ vec<gimple *> depends; /* Vector of statements that must be also
hoisted out of the loop when this statement
is hoisted; i.e. those that define the
operands of the statement and are inside of
@@ -586,27 +588,6 @@ simple_mem_ref_in_stmt (gimple *stmt, bool *is_store)
return NULL;
}
-/* Returns the memory reference contained in STMT. */
-
-static im_mem_ref *
-mem_ref_in_stmt (gimple *stmt)
-{
- bool store;
- tree *mem = simple_mem_ref_in_stmt (stmt, &store);
- hashval_t hash;
- im_mem_ref *ref;
-
- if (!mem)
- return NULL;
- gcc_assert (!store);
-
- hash = iterative_hash_expr (*mem, 0);
- ref = memory_accesses.refs->find_with_hash (*mem, hash);
-
- gcc_assert (ref != NULL);
- return ref;
-}
-
/* From a controlling predicate in DOM determine the arguments from
the PHI node PHI that are chosen if the predicate evaluates to
true and false and store them to *TRUE_ARG_P and *FALSE_ARG_P if
@@ -747,23 +728,18 @@ determine_max_movement (gimple *stmt, bool must_preserve_exec)
if (gimple_vuse (stmt))
{
- im_mem_ref *ref = mem_ref_in_stmt (stmt);
-
- if (ref)
+ im_mem_ref *ref
+ = lim_data ? memory_accesses.refs_list[lim_data->ref] : NULL;
+ if (ref
+ && MEM_ANALYZABLE (ref))
{
- lim_data->max_loop
- = outermost_indep_loop (lim_data->max_loop, loop, ref);
+ lim_data->max_loop = outermost_indep_loop (lim_data->max_loop,
+ loop, ref);
if (!lim_data->max_loop)
return false;
}
- else
- {
- if ((val = gimple_vuse (stmt)) != NULL_TREE)
- {
- if (!add_dependency (val, lim_data, loop, false))
- return false;
- }
- }
+ else if (! add_dependency (gimple_vuse (stmt), lim_data, loop, false))
+ return false;
}
lim_data->cost += stmt_cost (stmt);
@@ -1000,7 +976,9 @@ invariantness_dom_walker::before_dom_children (basic_block bb)
if (pos == MOVE_IMPOSSIBLE)
continue;
- lim_data = init_lim_data (stmt);
+ lim_data = get_lim_data (stmt);
+ if (! lim_data)
+ lim_data = init_lim_data (stmt);
lim_data->always_executed_in = outermost;
if (!determine_max_movement (stmt, false))
@@ -1037,7 +1015,9 @@ invariantness_dom_walker::before_dom_children (basic_block bb)
store-motion work. */
else if (stmt_makes_single_store (stmt))
{
- struct lim_aux_data *lim_data = init_lim_data (stmt);
+ struct lim_aux_data *lim_data = get_lim_data (stmt);
+ if (! lim_data)
+ lim_data = init_lim_data (stmt);
lim_data->always_executed_in = outermost;
}
continue;
@@ -1073,7 +1053,9 @@ invariantness_dom_walker::before_dom_children (basic_block bb)
stmt = rewrite_bittest (&bsi);
}
- lim_data = init_lim_data (stmt);
+ lim_data = get_lim_data (stmt);
+ if (! lim_data)
+ lim_data = init_lim_data (stmt);
lim_data->always_executed_in = outermost;
if (maybe_never && pos == MOVE_PRESERVE_EXECUTION)
@@ -1498,6 +1480,7 @@ gather_mem_refs_stmt (struct loop *loop, gimple *stmt)
bitmap_set_bit (&memory_accesses.refs_stored_in_loop[loop->num], ref->id);
mark_ref_stored (ref, loop);
}
+ init_lim_data (stmt)->ref = ref->id;
return;
}