diff options
author | Jeff Law <law@redhat.com> | 2015-09-18 20:56:15 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2015-09-18 20:56:15 -0600 |
commit | 8e33db8fc08900f77200506f2cdf5c50e2fbfcba (patch) | |
tree | 62af4cc89d09878673cfb0755453089addf8f45e /gcc/tree-ssa-threadedge.c | |
parent | 8788ec94173a9551076ee7d9f52b7f6c7afc9c68 (diff) | |
download | gcc-8e33db8fc08900f77200506f2cdf5c50e2fbfcba.zip gcc-8e33db8fc08900f77200506f2cdf5c50e2fbfcba.tar.gz gcc-8e33db8fc08900f77200506f2cdf5c50e2fbfcba.tar.bz2 |
[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
Diffstat (limited to 'gcc/tree-ssa-threadedge.c')
-rw-r--r-- | gcc/tree-ssa-threadedge.c | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 48c4ca7..ba25e07 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -56,6 +56,8 @@ static int stmt_count; /* Array to record value-handles per SSA_NAME. */ 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. */ void @@ -256,10 +258,10 @@ fold_assignment_stmt (gimple stmt) static gimple record_temporary_equivalences_from_stmts_at_dest (edge e, - const_and_copies *const_and_copies, - tree (*simplify) (gimple, - gimple), - bool backedge_seen) + const_and_copies *const_and_copies, + avail_exprs_stack *avail_exprs_stack, + pfn_simplify simplify, + bool backedge_seen) { gimple stmt = NULL; gimple_stmt_iterator gsi; @@ -412,7 +414,7 @@ record_temporary_equivalences_from_stmts_at_dest (edge e, if (!cached_lhs || (TREE_CODE (cached_lhs) != SSA_NAME && !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. */ i = 0; @@ -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 DOM/VRP to achieve that effect. */ 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; } @@ -459,13 +462,16 @@ dummy_simplify (gimple stmt1 ATTRIBUTE_UNUSED, gimple stmt2 ATTRIBUTE_UNUSED) a condition using pass specific information. 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 simplify_control_stmt_condition (edge e, gimple stmt, + class avail_exprs_stack *avail_exprs_stack, gcond *dummy_cond, - tree (*simplify) (gimple, gimple), + pfn_simplify simplify, bool handle_dominating_asserts) { tree cond, cached_lhs; @@ -552,7 +558,7 @@ simplify_control_stmt_condition (edge e, then use the pass specific callback to simplify the condition. */ if (!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 failed, just return the first operand. This gives the FSM code a @@ -614,7 +620,7 @@ simplify_control_stmt_condition (edge e, /* If we haven't simplified to an invariant yet, then use the pass specific callback to try and simplify it further. */ 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 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) return false. 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 thread_around_empty_blocks (edge taken_edge, gcond *dummy_cond, + class avail_exprs_stack *avail_exprs_stack, bool handle_dominating_asserts, - tree (*simplify) (gimple, gimple), + pfn_simplify simplify, bitmap visited, vec<jump_thread_edge *> *path, bool *backedge_seen_p) @@ -818,6 +828,7 @@ thread_around_empty_blocks (edge taken_edge, simplify = dummy_simplify; return thread_around_empty_blocks (taken_edge, dummy_cond, + avail_exprs_stack, handle_dominating_asserts, simplify, visited, @@ -846,7 +857,8 @@ thread_around_empty_blocks (edge taken_edge, simplify = dummy_simplify; /* 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); /* If the condition can be statically computed and we have not already @@ -869,6 +881,7 @@ thread_around_empty_blocks (edge taken_edge, thread_around_empty_blocks (taken_edge, dummy_cond, + avail_exprs_stack, handle_dominating_asserts, simplify, visited, @@ -1187,7 +1200,8 @@ thread_through_normal_block (edge e, gcond *dummy_cond, bool handle_dominating_asserts, const_and_copies *const_and_copies, - tree (*simplify) (gimple, gimple), + avail_exprs_stack *avail_exprs_stack, + pfn_simplify simplify, vec<jump_thread_edge *> *path, bitmap visited, bool *backedge_seen_p) @@ -1210,6 +1224,7 @@ thread_through_normal_block (edge e, temporary equivalences we can detect. */ gimple stmt = record_temporary_equivalences_from_stmts_at_dest (e, const_and_copies, + avail_exprs_stack, simplify, *backedge_seen_p); @@ -1248,7 +1263,8 @@ thread_through_normal_block (edge e, tree cond; /* 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); if (!cond) @@ -1293,6 +1309,7 @@ thread_through_normal_block (edge e, bitmap_set_bit (visited, e->dest->index); thread_around_empty_blocks (taken_edge, dummy_cond, + avail_exprs_stack, handle_dominating_asserts, simplify, visited, @@ -1348,8 +1365,10 @@ thread_through_normal_block (edge e, the simplified condition with left-hand sides of ASSERT_EXPRs they are used in. - STACK is used to undo temporary equivalences created during the walk of - E->dest. + CONST_AND_COPIES is used to undo temporary equivalences created during the + walk of E->dest. + + The available expression table is referenced vai AVAIL_EXPRS_STACK. SIMPLIFY is a pass-specific function used to simplify statements. */ @@ -1357,9 +1376,10 @@ void thread_across_edge (gcond *dummy_cond, edge e, bool handle_dominating_asserts, - const_and_copies *const_and_copies, - avail_exprs_stack *avail_exprs_stack, - tree (*simplify) (gimple, gimple)) + class const_and_copies *const_and_copies, + class avail_exprs_stack *avail_exprs_stack, + tree (*simplify) (gimple, gimple, + class avail_exprs_stack *)) { bitmap visited = BITMAP_ALLOC (NULL); bool backedge_seen; @@ -1376,7 +1396,9 @@ thread_across_edge (gcond *dummy_cond, int threaded = thread_through_normal_block (e, dummy_cond, handle_dominating_asserts, - const_and_copies, simplify, path, + const_and_copies, + avail_exprs_stack, + simplify, path, visited, &backedge_seen); if (threaded > 0) { @@ -1467,6 +1489,7 @@ thread_across_edge (gcond *dummy_cond, simplify = dummy_simplify; found = thread_around_empty_blocks (taken_edge, dummy_cond, + avail_exprs_stack, handle_dominating_asserts, simplify, visited, @@ -1479,7 +1502,9 @@ thread_across_edge (gcond *dummy_cond, if (!found) found = thread_through_normal_block (path->last ()->e, dummy_cond, handle_dominating_asserts, - const_and_copies, simplify, path, + const_and_copies, + avail_exprs_stack, + simplify, path, visited, &backedge_seen) > 0; /* If we were able to thread through a successor of E->dest, then |