diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2020-11-21 18:26:21 +0100 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-04-30 18:17:17 +0200 |
commit | d8ea47033a726c9b3455ead98b6ddce2403ec6d9 (patch) | |
tree | c9a74b07b091406b717571a92bbbc06ae7599584 /gcc/tree-ssa-threadbackward.c | |
parent | 71834be5b68e0c9839f0647e1bbf1eec4e4bbf49 (diff) | |
download | gcc-d8ea47033a726c9b3455ead98b6ddce2403ec6d9.zip gcc-d8ea47033a726c9b3455ead98b6ddce2403ec6d9.tar.gz gcc-d8ea47033a726c9b3455ead98b6ddce2403ec6d9.tar.bz2 |
Jump threader refactor.
This is an overall refactor of the jump threader, both for the low level
bits in tree-ssa-threadupdate.* and the high level bits in
tree-ssa-threadedge.*.
There should be no functional changes.
Some of the benefits of the refactor are:
a) Eliminates some icky global state (for example the x_vr_values hack).
b) Provides some semblance of an API for the threader.
c) Makes it clearer to see what parts are from the high level
threader, and what parts belong in the low level path registry and
BB threading mechanism.
d) Avoids passing a ton of variables around.
e) Provides for easier sharing with the backward threader.
f) Merged simplify stmt code in VRP and DOM as they were nearly
identical.
This has been bootstrapped and regression tested on x86-64 Linux.
Jeff had also been testing this path as part of his Fedora throughout the
off-season.
gcc/ChangeLog:
* tree-ssa-dom.c (class dom_jump_threader_simplifier): New.
(class dom_opt_dom_walker): Initialize some class variables.
(pass_dominator::execute): Pass evrp_range_analyzer and
dom_jump_threader_simplifier to dom_opt_dom_walker.
Adjust for some functions moving into classes.
(simplify_stmt_for_jump_threading): Adjust and move to...
(jump_threader_simplifier::simplify): ...here.
(dom_opt_dom_walker::before_dom_children): Adjust for
m_evrp_range_analyzer.
(dom_opt_dom_walker::after_dom_children): Remove x_vr_values hack.
(test_for_singularity): Place in dom_opt_dom_walker class.
(dom_opt_dom_walker::optimize_stmt): The argument
evrp_range_analyzer is now a class field.
* tree-ssa-threadbackward.c (class thread_jumps): Add m_registry.
(thread_jumps::thread_through_all_blocks): New.
(thread_jumps::convert_and_register_current_path): Use m_registry.
(pass_thread_jumps::execute): Adjust for thread_through_all_blocks
being in the threader class.
(pass_early_thread_jumps::execute): Same.
* tree-ssa-threadedge.c (threadedge_initialize_values): Move...
(jump_threader::jump_threader): ...here.
(threadedge_finalize_values): Move...
(jump_threader::~jump_threader): ...here.
(jump_threader::remove_jump_threads_including): New.
(jump_threader::thread_through_all_blocks): New.
(record_temporary_equivalences_from_phis): Move...
(jump_threader::record_temporary_equivalences_from_phis): ...here.
(record_temporary_equivalences_from_stmts_at_dest): Move...
(jump_threader::record_temporary_equivalences_from_stmts_at_dest):
Here...
(simplify_control_stmt_condition_1): Move to jump_threader class.
(simplify_control_stmt_condition): Move...
(jump_threader::simplify_control_stmt_condition): ...here.
(thread_around_empty_blocks): Move...
(jump_threader::thread_around_empty_blocks): ...here.
(thread_through_normal_block): Move...
(jump_threader::thread_through_normal_block): ...here.
(thread_across_edge): Move...
(jump_threader::thread_across_edge): ...here.
(thread_outgoing_edges): Move...
(jump_threader::thread_outgoing_edges): ...here.
* tree-ssa-threadedge.h: Move externally facing functings...
(class jump_threader): ...here...
(class jump_threader_simplifier): ...and here.
* tree-ssa-threadupdate.c (struct redirection_data): Remove comment.
(jump_thread_path_allocator::jump_thread_path_allocator): New.
(jump_thread_path_allocator::~jump_thread_path_allocator): New.
(jump_thread_path_allocator::allocate_thread_edge): New.
(jump_thread_path_allocator::allocate_thread_path): New.
(jump_thread_path_registry::jump_thread_path_registry): New.
(jump_thread_path_registry::~jump_thread_path_registry): New.
(jump_thread_path_registry::allocate_thread_edge): New.
(jump_thread_path_registry::allocate_thread_path): New.
(dump_jump_thread_path): Make extern.
(debug (const vec<jump_thread_edge *> &path)): New.
(struct removed_edges): Move to tree-ssa-threadupdate.h.
(struct thread_stats_d): Remove.
(remove_ctrl_stmt_and_useless_edges): Make static.
(lookup_redirection_data): Move...
(jump_thread_path_registry::lookup_redirection_data): ...here.
(ssa_redirect_edges): Make static.
(thread_block_1): Move...
(jump_thread_path_registry::thread_block_1): ...here.
(thread_block): Move...
(jump_thread_path_registry::thread_block): ...here.
(thread_through_loop_header): Move...
(jump_thread_path_registry::thread_through_loop_header): ...here.
(mark_threaded_blocks): Move...
(jump_thread_path_registry::mark_threaded_blocks): ...here.
(debug_path): Move...
(jump_thread_path_registry::debug_path): ...here.
(debug_all_paths): Move...
(jump_thread_path_registry::dump): ..here.
(rewire_first_differing_edge): Move...
(jump_thread_path_registry::rewire_first_differing_edge): ...here.
(adjust_paths_after_duplication): Move...
(jump_thread_path_registry::adjust_paths_after_duplication): ...here.
(duplicate_thread_path): Move...
(jump_thread_path_registry::duplicate_thread_path): ..here.
(remove_jump_threads_including): Move...
(jump_thread_path_registry::remove_jump_threads_including): ...here.
(thread_through_all_blocks): Move to...
(jump_thread_path_registry::thread_through_all_blocks): ...here.
(delete_jump_thread_path): Remove.
(register_jump_thread): Move...
(jump_thread_path_registry::register_jump_thread): ...here.
* tree-ssa-threadupdate.h: Move externally facing functions...
(class jump_thread_path_allocator): ...here...
(class jump_thread_path_registry): ...and here.
(thread_through_all_blocks): Remove.
(struct removed_edges): New.
(register_jump_thread): Remove.
(remove_jump_threads_including): Remove.
(delete_jump_thread_path): Remove.
(remove_ctrl_stmt_and_useless_edges): Remove.
(free_dom_edge_info): New prototype.
* tree-vrp.c: Remove x_vr_values hack.
(class vrp_jump_threader_simplifier): New.
(vrp_jump_threader_simplifier::simplify): New.
(vrp_jump_threader::vrp_jump_threader): Adjust method signature.
Remove m_dummy_cond.
Instantiate m_simplifier and m_threader.
(vrp_jump_threader::thread_through_all_blocks): New.
(vrp_jump_threader::simplify_stmt): Remove.
(vrp_jump_threader::after_dom_children): Do not set m_dummy_cond.
Remove x_vr_values hack.
(execute_vrp): Adjust for thread_through_all_blocks being in a
class.
Diffstat (limited to 'gcc/tree-ssa-threadbackward.c')
-rw-r--r-- | gcc/tree-ssa-threadbackward.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 515a94b..428cf07 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -39,9 +39,11 @@ along with GCC; see the file COPYING3. If not see class thread_jumps { - public: +public: void find_jump_threads_backwards (basic_block bb, bool speed_p); - private: + bool thread_through_all_blocks (); + +private: edge profitable_jump_thread_path (basic_block bbi, tree name, tree arg, bool *creates_irreducible_loop); void convert_and_register_current_path (edge taken_edge); @@ -65,8 +67,16 @@ class thread_jumps /* Indicate that we could increase code size to improve the code path. */ bool m_speed_p; + + jump_thread_path_registry m_registry; }; +bool +thread_jumps::thread_through_all_blocks () +{ + return m_registry.thread_through_all_blocks (true); +} + /* Simple helper to get the last statement from BB, which is assumed to be a control statement. Return NULL if the last statement is not a control statement. */ @@ -459,7 +469,7 @@ thread_jumps::profitable_jump_thread_path (basic_block bbi, tree name, void thread_jumps::convert_and_register_current_path (edge taken_edge) { - vec<jump_thread_edge *> *jump_thread_path = new vec<jump_thread_edge *> (); + vec<jump_thread_edge *> *path = m_registry.allocate_thread_path (); /* Record the edges between the blocks in PATH. */ for (unsigned int j = 0; j + 1 < m_path.length (); j++) @@ -469,16 +479,17 @@ thread_jumps::convert_and_register_current_path (edge taken_edge) edge e = find_edge (bb1, bb2); gcc_assert (e); - jump_thread_edge *x = new jump_thread_edge (e, EDGE_FSM_THREAD); - jump_thread_path->safe_push (x); + jump_thread_edge *x + = m_registry.allocate_thread_edge (e, EDGE_FSM_THREAD); + path->safe_push (x); } /* Add the edge taken when the control variable has value ARG. */ jump_thread_edge *x - = new jump_thread_edge (taken_edge, EDGE_NO_COPY_SRC_BLOCK); - jump_thread_path->safe_push (x); + = m_registry.allocate_thread_edge (taken_edge, EDGE_NO_COPY_SRC_BLOCK); + path->safe_push (x); - register_jump_thread (jump_thread_path); + m_registry.register_jump_thread (path); --m_max_threaded_paths; } @@ -827,7 +838,7 @@ pass_thread_jumps::execute (function *fun) if (EDGE_COUNT (bb->succs) > 1) threader.find_jump_threads_backwards (bb, true); } - bool changed = thread_through_all_blocks (true); + bool changed = threader.thread_through_all_blocks (); loop_optimizer_finalize (); return changed ? TODO_cleanup_cfg : 0; @@ -888,7 +899,7 @@ pass_early_thread_jumps::execute (function *fun) if (EDGE_COUNT (bb->succs) > 1) threader.find_jump_threads_backwards (bb, false); } - thread_through_all_blocks (true); + threader.thread_through_all_blocks (); loop_optimizer_finalize (); return 0; |