On 4/28/2021 11:12 AM, Aldy Hernandez wrote:
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).

Thank goodness.  This was the biggest wart from the VRP refactoring a couple years back.



b) Provides some semblance of an API for the threader.

Definitely good.  As you've noted, there's a few distinct phases (simplification for threading, registering threadinng opportunities, realization of threading opportunities).  There's a relatively narrow interface between each and putting a real API in between those phases is definitely an improvement.



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.

Exactly.  I wouldn't lose any sleep if the registry bits moved into their own file.



d) Avoids passing a ton of variables around.

Yea.  I had some similar patches here -- as various routines move into classes we don't need that nonsense anymore.



e) Provides for easier sharing with the backward threader.

f) Merges the simplify stmt code in VRP and DOM as they were nearly
identical.

Yea.  I can't even remember why those bits weren't shared.  They should have been damn close to 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.

More correctly, it's been in the Upstream GCC tester for months, so it's been tested across various native and embedded targets.


The Fedora tester is different :-)  I'm hoping to get the Fedora snapshot tester fired up again next week so that we're building Fedora against GCC snapshots regularly for at least x86_64 and aarch64.





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.

OK.  Thanks for taking care of this.

jeff

Reply via email to