Commit 8e33db8f by Jeff Law Committed by Jeff Law

[PATCH] avail_expr_stack is no longer file scoped

       PR tree-optimization/47679
        * tree-ssa-dom.c (avail_exprs_stack): No longer file scoped.  Move
        it here ...
        (dom_opt_dom_walker): New private member holding the avail_exprs_stack
        object.  Update constructor.
        (pass_dominator::execute):  Corresponding chagnes to declaration
        and initialization of avail_exprs_stack.  Update constructor call
        for dom_opt_dom_walker object.
        (lookup_avail_expr, record_cond): Accept additional argument.  Pass
        it down to children as needed.
        (record_equivalences_from_incoming_edge): Likewise.
        (eliminate_redundant_computations): Likewise.
        (record_equivalences_from_stmt): Likewise.
        (simplify_stmt_for_jump_threading): Likewise.
        (record_temporary_equivalences): Likewise.
        (optimize_stmt): Likewise.
        (dom_opt_dom_walker::thread_across_edge): Update access to
        avail_exprs_stack object and pass it to children as needed.
        (dom_opt_dom_walker::before_dom_children): Similarly.
        (dom_opt_dom_walker::after_dom_children): Similarly.
        * tree-ssa-threadedge.c (pfn_simplify): New typedef.
        (record_temporary_equivalences_from_stmts_at_dest): Use new typedef.
        Add avail_expr_stack argument.  Pass it to children as needed.
        (dummy_simplify): Likewise.
        (simplify_control_stmt_condition): Likewise.
        (thread_around_empty_blocks): Likewise.
        (thread_through_normal_block): Likewise.
        (thread_across_edge): Likewise.
        * tree-ssa-threadedge.h (thread_across_edge): Update prototype.
        * tree-vrp.c (simplify_stmt_for_jump_threading): Update.

From-SVN: r227931
parent 8788ec94
2015-09-18 Jeff Law <law@redhat.com> 2015-09-18 Jeff Law <law@redhat.com>
PR tree-optimization/47679 PR tree-optimization/47679
* tree-ssa-dom.c (avail_exprs_stack): No longer file scoped. Move
it here ...
(dom_opt_dom_walker): New private member holding the avail_exprs_stack
object. Update constructor.
(pass_dominator::execute): Corresponding chagnes to declaration
and initialization of avail_exprs_stack. Update constructor call
for dom_opt_dom_walker object.
(lookup_avail_expr, record_cond): Accept additional argument. Pass
it down to children as needed.
(record_equivalences_from_incoming_edge): Likewise.
(eliminate_redundant_computations): Likewise.
(record_equivalences_from_stmt): Likewise.
(simplify_stmt_for_jump_threading): Likewise.
(record_temporary_equivalences): Likewise.
(optimize_stmt): Likewise.
(dom_opt_dom_walker::thread_across_edge): Update access to
avail_exprs_stack object and pass it to children as needed.
(dom_opt_dom_walker::before_dom_children): Similarly.
(dom_opt_dom_walker::after_dom_children): Similarly.
* tree-ssa-threadedge.c (pfn_simplify): New typedef.
(record_temporary_equivalences_from_stmts_at_dest): Use new typedef.
Add avail_expr_stack argument. Pass it to children as needed.
(dummy_simplify): Likewise.
(simplify_control_stmt_condition): Likewise.
(thread_around_empty_blocks): Likewise.
(thread_through_normal_block): Likewise.
(thread_across_edge): Likewise.
* tree-ssa-threadedge.h (thread_across_edge): Update prototype.
* tree-vrp.c (simplify_stmt_for_jump_threading): Update.
PR tree-optimization/47679
* tree-ssa-dom.c (const_and_copies): No longer file scoped. Move * tree-ssa-dom.c (const_and_copies): No longer file scoped. Move
it here ... it here ...
(dom_opt_dom_walker): New private member holding the const_and_copies (dom_opt_dom_walker): New private member holding the const_and_copies
...@@ -56,6 +56,8 @@ static int stmt_count; ...@@ -56,6 +56,8 @@ static int stmt_count;
/* Array to record value-handles per SSA_NAME. */ /* Array to record value-handles per SSA_NAME. */
vec<tree> ssa_name_values; vec<tree> ssa_name_values;
typedef tree (pfn_simplify) (gimple, gimple, class avail_exprs_stack *);
/* Set the value for the SSA name NAME to VALUE. */ /* Set the value for the SSA name NAME to VALUE. */
void void
...@@ -256,10 +258,10 @@ fold_assignment_stmt (gimple stmt) ...@@ -256,10 +258,10 @@ fold_assignment_stmt (gimple stmt)
static gimple static gimple
record_temporary_equivalences_from_stmts_at_dest (edge e, record_temporary_equivalences_from_stmts_at_dest (edge e,
const_and_copies *const_and_copies, const_and_copies *const_and_copies,
tree (*simplify) (gimple, avail_exprs_stack *avail_exprs_stack,
gimple), pfn_simplify simplify,
bool backedge_seen) bool backedge_seen)
{ {
gimple stmt = NULL; gimple stmt = NULL;
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
...@@ -412,7 +414,7 @@ record_temporary_equivalences_from_stmts_at_dest (edge e, ...@@ -412,7 +414,7 @@ record_temporary_equivalences_from_stmts_at_dest (edge e,
if (!cached_lhs if (!cached_lhs
|| (TREE_CODE (cached_lhs) != SSA_NAME || (TREE_CODE (cached_lhs) != SSA_NAME
&& !is_gimple_min_invariant (cached_lhs))) && !is_gimple_min_invariant (cached_lhs)))
cached_lhs = (*simplify) (stmt, stmt); cached_lhs = (*simplify) (stmt, stmt, avail_exprs_stack);
/* Restore the statement's original uses/defs. */ /* Restore the statement's original uses/defs. */
i = 0; i = 0;
...@@ -445,7 +447,8 @@ record_temporary_equivalences_from_stmts_at_dest (edge e, ...@@ -445,7 +447,8 @@ record_temporary_equivalences_from_stmts_at_dest (edge e,
necessarily valid. We use this callback rather than the ones provided by necessarily valid. We use this callback rather than the ones provided by
DOM/VRP to achieve that effect. */ DOM/VRP to achieve that effect. */
static tree static tree
dummy_simplify (gimple stmt1 ATTRIBUTE_UNUSED, gimple stmt2 ATTRIBUTE_UNUSED) dummy_simplify (gimple stmt1 ATTRIBUTE_UNUSED, gimple stmt2 ATTRIBUTE_UNUSED,
class avail_exprs_stack *avail_exprs_stack ATTRIBUTE_UNUSED)
{ {
return NULL_TREE; return NULL_TREE;
} }
...@@ -459,13 +462,16 @@ dummy_simplify (gimple stmt1 ATTRIBUTE_UNUSED, gimple stmt2 ATTRIBUTE_UNUSED) ...@@ -459,13 +462,16 @@ dummy_simplify (gimple stmt1 ATTRIBUTE_UNUSED, gimple stmt2 ATTRIBUTE_UNUSED)
a condition using pass specific information. a condition using pass specific information.
Return the simplified condition or NULL if simplification could Return the simplified condition or NULL if simplification could
not be performed. */ not be performed.
The available expression table is referenced via AVAIL_EXPRS_STACK. */
static tree static tree
simplify_control_stmt_condition (edge e, simplify_control_stmt_condition (edge e,
gimple stmt, gimple stmt,
class avail_exprs_stack *avail_exprs_stack,
gcond *dummy_cond, gcond *dummy_cond,
tree (*simplify) (gimple, gimple), pfn_simplify simplify,
bool handle_dominating_asserts) bool handle_dominating_asserts)
{ {
tree cond, cached_lhs; tree cond, cached_lhs;
...@@ -552,7 +558,7 @@ simplify_control_stmt_condition (edge e, ...@@ -552,7 +558,7 @@ simplify_control_stmt_condition (edge e,
then use the pass specific callback to simplify the condition. */ then use the pass specific callback to simplify the condition. */
if (!cached_lhs if (!cached_lhs
|| !is_gimple_min_invariant (cached_lhs)) || !is_gimple_min_invariant (cached_lhs))
cached_lhs = (*simplify) (dummy_cond, stmt); cached_lhs = (*simplify) (dummy_cond, stmt, avail_exprs_stack);
/* If we were just testing that an integral type was != 0, and that /* If we were just testing that an integral type was != 0, and that
failed, just return the first operand. This gives the FSM code a failed, just return the first operand. This gives the FSM code a
...@@ -614,7 +620,7 @@ simplify_control_stmt_condition (edge e, ...@@ -614,7 +620,7 @@ simplify_control_stmt_condition (edge e,
/* If we haven't simplified to an invariant yet, then use the /* If we haven't simplified to an invariant yet, then use the
pass specific callback to try and simplify it further. */ pass specific callback to try and simplify it further. */
if (cached_lhs && ! is_gimple_min_invariant (cached_lhs)) if (cached_lhs && ! is_gimple_min_invariant (cached_lhs))
cached_lhs = (*simplify) (stmt, stmt); cached_lhs = (*simplify) (stmt, stmt, avail_exprs_stack);
/* We couldn't find an invariant. But, callers of this /* We couldn't find an invariant. But, callers of this
function may be able to do something useful with the function may be able to do something useful with the
...@@ -764,12 +770,16 @@ propagate_threaded_block_debug_into (basic_block dest, basic_block src) ...@@ -764,12 +770,16 @@ propagate_threaded_block_debug_into (basic_block dest, basic_block src)
return false. return false.
DUMMY_COND, HANDLE_DOMINATING_ASSERTS and SIMPLIFY are used to DUMMY_COND, HANDLE_DOMINATING_ASSERTS and SIMPLIFY are used to
try and simplify the condition at the end of TAKEN_EDGE->dest. */ try and simplify the condition at the end of TAKEN_EDGE->dest.
The available expression table is referenced via AVAIL_EXPRS_STACK. */
static bool static bool
thread_around_empty_blocks (edge taken_edge, thread_around_empty_blocks (edge taken_edge,
gcond *dummy_cond, gcond *dummy_cond,
class avail_exprs_stack *avail_exprs_stack,
bool handle_dominating_asserts, bool handle_dominating_asserts,
tree (*simplify) (gimple, gimple), pfn_simplify simplify,
bitmap visited, bitmap visited,
vec<jump_thread_edge *> *path, vec<jump_thread_edge *> *path,
bool *backedge_seen_p) bool *backedge_seen_p)
...@@ -818,6 +828,7 @@ thread_around_empty_blocks (edge taken_edge, ...@@ -818,6 +828,7 @@ thread_around_empty_blocks (edge taken_edge,
simplify = dummy_simplify; simplify = dummy_simplify;
return thread_around_empty_blocks (taken_edge, return thread_around_empty_blocks (taken_edge,
dummy_cond, dummy_cond,
avail_exprs_stack,
handle_dominating_asserts, handle_dominating_asserts,
simplify, simplify,
visited, visited,
...@@ -846,7 +857,8 @@ thread_around_empty_blocks (edge taken_edge, ...@@ -846,7 +857,8 @@ thread_around_empty_blocks (edge taken_edge,
simplify = dummy_simplify; simplify = dummy_simplify;
/* Extract and simplify the condition. */ /* Extract and simplify the condition. */
cond = simplify_control_stmt_condition (taken_edge, stmt, dummy_cond, cond = simplify_control_stmt_condition (taken_edge, stmt,
avail_exprs_stack, dummy_cond,
simplify, handle_dominating_asserts); simplify, handle_dominating_asserts);
/* If the condition can be statically computed and we have not already /* If the condition can be statically computed and we have not already
...@@ -869,6 +881,7 @@ thread_around_empty_blocks (edge taken_edge, ...@@ -869,6 +881,7 @@ thread_around_empty_blocks (edge taken_edge,
thread_around_empty_blocks (taken_edge, thread_around_empty_blocks (taken_edge,
dummy_cond, dummy_cond,
avail_exprs_stack,
handle_dominating_asserts, handle_dominating_asserts,
simplify, simplify,
visited, visited,
...@@ -1187,7 +1200,8 @@ thread_through_normal_block (edge e, ...@@ -1187,7 +1200,8 @@ thread_through_normal_block (edge e,
gcond *dummy_cond, gcond *dummy_cond,
bool handle_dominating_asserts, bool handle_dominating_asserts,
const_and_copies *const_and_copies, const_and_copies *const_and_copies,
tree (*simplify) (gimple, gimple), avail_exprs_stack *avail_exprs_stack,
pfn_simplify simplify,
vec<jump_thread_edge *> *path, vec<jump_thread_edge *> *path,
bitmap visited, bitmap visited,
bool *backedge_seen_p) bool *backedge_seen_p)
...@@ -1210,6 +1224,7 @@ thread_through_normal_block (edge e, ...@@ -1210,6 +1224,7 @@ thread_through_normal_block (edge e,
temporary equivalences we can detect. */ temporary equivalences we can detect. */
gimple stmt gimple stmt
= record_temporary_equivalences_from_stmts_at_dest (e, const_and_copies, = record_temporary_equivalences_from_stmts_at_dest (e, const_and_copies,
avail_exprs_stack,
simplify, simplify,
*backedge_seen_p); *backedge_seen_p);
...@@ -1248,7 +1263,8 @@ thread_through_normal_block (edge e, ...@@ -1248,7 +1263,8 @@ thread_through_normal_block (edge e,
tree cond; tree cond;
/* Extract and simplify the condition. */ /* Extract and simplify the condition. */
cond = simplify_control_stmt_condition (e, stmt, dummy_cond, simplify, cond = simplify_control_stmt_condition (e, stmt, avail_exprs_stack,
dummy_cond, simplify,
handle_dominating_asserts); handle_dominating_asserts);
if (!cond) if (!cond)
...@@ -1293,6 +1309,7 @@ thread_through_normal_block (edge e, ...@@ -1293,6 +1309,7 @@ thread_through_normal_block (edge e,
bitmap_set_bit (visited, e->dest->index); bitmap_set_bit (visited, e->dest->index);
thread_around_empty_blocks (taken_edge, thread_around_empty_blocks (taken_edge,
dummy_cond, dummy_cond,
avail_exprs_stack,
handle_dominating_asserts, handle_dominating_asserts,
simplify, simplify,
visited, visited,
...@@ -1348,8 +1365,10 @@ thread_through_normal_block (edge e, ...@@ -1348,8 +1365,10 @@ thread_through_normal_block (edge e,
the simplified condition with left-hand sides of ASSERT_EXPRs they are the simplified condition with left-hand sides of ASSERT_EXPRs they are
used in. used in.
STACK is used to undo temporary equivalences created during the walk of CONST_AND_COPIES is used to undo temporary equivalences created during the
E->dest. walk of E->dest.
The available expression table is referenced vai AVAIL_EXPRS_STACK.
SIMPLIFY is a pass-specific function used to simplify statements. */ SIMPLIFY is a pass-specific function used to simplify statements. */
...@@ -1357,9 +1376,10 @@ void ...@@ -1357,9 +1376,10 @@ void
thread_across_edge (gcond *dummy_cond, thread_across_edge (gcond *dummy_cond,
edge e, edge e,
bool handle_dominating_asserts, bool handle_dominating_asserts,
const_and_copies *const_and_copies, class const_and_copies *const_and_copies,
avail_exprs_stack *avail_exprs_stack, class avail_exprs_stack *avail_exprs_stack,
tree (*simplify) (gimple, gimple)) tree (*simplify) (gimple, gimple,
class avail_exprs_stack *))
{ {
bitmap visited = BITMAP_ALLOC (NULL); bitmap visited = BITMAP_ALLOC (NULL);
bool backedge_seen; bool backedge_seen;
...@@ -1376,7 +1396,9 @@ thread_across_edge (gcond *dummy_cond, ...@@ -1376,7 +1396,9 @@ thread_across_edge (gcond *dummy_cond,
int threaded = thread_through_normal_block (e, dummy_cond, int threaded = thread_through_normal_block (e, dummy_cond,
handle_dominating_asserts, handle_dominating_asserts,
const_and_copies, simplify, path, const_and_copies,
avail_exprs_stack,
simplify, path,
visited, &backedge_seen); visited, &backedge_seen);
if (threaded > 0) if (threaded > 0)
{ {
...@@ -1467,6 +1489,7 @@ thread_across_edge (gcond *dummy_cond, ...@@ -1467,6 +1489,7 @@ thread_across_edge (gcond *dummy_cond,
simplify = dummy_simplify; simplify = dummy_simplify;
found = thread_around_empty_blocks (taken_edge, found = thread_around_empty_blocks (taken_edge,
dummy_cond, dummy_cond,
avail_exprs_stack,
handle_dominating_asserts, handle_dominating_asserts,
simplify, simplify,
visited, visited,
...@@ -1479,7 +1502,9 @@ thread_across_edge (gcond *dummy_cond, ...@@ -1479,7 +1502,9 @@ thread_across_edge (gcond *dummy_cond,
if (!found) if (!found)
found = thread_through_normal_block (path->last ()->e, dummy_cond, found = thread_through_normal_block (path->last ()->e, dummy_cond,
handle_dominating_asserts, handle_dominating_asserts,
const_and_copies, simplify, path, const_and_copies,
avail_exprs_stack,
simplify, path,
visited, &backedge_seen) > 0; visited, &backedge_seen) > 0;
/* If we were able to thread through a successor of E->dest, then /* If we were able to thread through a successor of E->dest, then
......
...@@ -33,6 +33,6 @@ extern void propagate_threaded_block_debug_into (basic_block, basic_block); ...@@ -33,6 +33,6 @@ extern void propagate_threaded_block_debug_into (basic_block, basic_block);
extern void thread_across_edge (gcond *, edge, bool, extern void thread_across_edge (gcond *, edge, bool,
const_and_copies *, const_and_copies *,
avail_exprs_stack *, avail_exprs_stack *,
tree (*) (gimple, gimple)); tree (*) (gimple, gimple, avail_exprs_stack *));
#endif /* GCC_TREE_SSA_THREADEDGE_H */ #endif /* GCC_TREE_SSA_THREADEDGE_H */
...@@ -10066,7 +10066,8 @@ const_and_copies *equiv_stack; ...@@ -10066,7 +10066,8 @@ const_and_copies *equiv_stack;
for any overflow warnings. */ for any overflow warnings. */
static tree static tree
simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt) simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt,
class avail_exprs_stack *avail_exprs_stack ATTRIBUTE_UNUSED)
{ {
if (gcond *cond_stmt = dyn_cast <gcond *> (stmt)) if (gcond *cond_stmt = dyn_cast <gcond *> (stmt))
return vrp_evaluate_conditional (gimple_cond_code (cond_stmt), return vrp_evaluate_conditional (gimple_cond_code (cond_stmt),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment