https://gcc.gnu.org/g:75cc549c46188b02b736d2d0e4dfdbf6031293c3
commit r17-4983-g75cc549c46188b02b736d2d0e4dfdbf6031293c3 Author: Aldy Hernandez <[email protected]> Date: Wed Oct 7 08:07:50 2026 +0000 backward threader: split the search from applying the threads Split the thread search functionality from the threading of such. This will make it cleaner for subsequent work to thread in the FRE pass as discussed in PRPR126904. Tested on ppc64le Linux. gcc/ChangeLog: * tree-ssa-threadbackward.cc (class back_threader): Add search and apply; make the destructor virtual. (back_threader::search): New, split out of thread_blocks. (back_threader::apply): Same. (back_threader::thread_blocks): Call them. Diff: --- gcc/tree-ssa-threadbackward.cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index 99e88e5e8f34..1a3a4e361957 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -207,8 +207,10 @@ class back_threader { public: back_threader (function *fun, unsigned flags, bool first); - ~back_threader (); + virtual ~back_threader (); unsigned thread_blocks (); + void search (); + unsigned apply (); private: void maybe_thread_block (basic_block bb); bool debug_counter (); @@ -984,18 +986,22 @@ back_threader_registry::register_path (const vec<basic_block> &m_path, return register_jump_thread (jump_thread_path); } -// Thread all suitable paths in the current function. -// -// Return TODO_flags. +// Find the paths to thread in the current function. -unsigned int -back_threader::thread_blocks () +void +back_threader::search () { basic_block bb; FOR_EACH_BB_FN (bb, m_fun) if (EDGE_COUNT (bb->succs) > 1) maybe_thread_block (bb); +} + +// Thread the paths found. Return TODO_flags. +unsigned int +back_threader::apply () +{ bool changed = m_registry.thread_through_all_blocks (true); if (m_flags & BT_SPEED) @@ -1004,6 +1010,17 @@ back_threader::thread_blocks () return false; } +// Thread all suitable paths in the current function. +// +// Return TODO_flags. + +unsigned int +back_threader::thread_blocks () +{ + search (); + return apply (); +} + namespace { const pass_data pass_data_early_thread_jumps =
