https://gcc.gnu.org/g:e7426f3f0dfacc5c40c84eb914ecfe62557bfacd
commit r16-8884-ge7426f3f0dfacc5c40c84eb914ecfe62557bfacd Author: Richard Biener <[email protected]> Date: Fri May 8 08:16:26 2026 +0200 Revert "tree-optimization/120003 - missed jump threading" This reverts commit 1a13684dfc7286139064f7d7341462c9995cbd1c. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-23.c | 19 ------------------- gcc/tree-ssa-threadbackward.cc | 8 +++++--- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-23.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-23.c deleted file mode 100644 index 930360a33b57..000000000000 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-23.c +++ /dev/null @@ -1,19 +0,0 @@ -/* PR120003 */ -/* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-cddce3-details" } */ - -extern _Bool g(int); - -_Bool f() -{ - _Bool retval = 0; - for(int i=0; i<1000000; ++i) - retval = retval || g(i); - return retval; -} - -/* Jump threading after loop optimization should get the counting loop - separated from the loop until retval is true and CD-DCE elide it. - It's difficult to check for the fact that a true retval terminates - the loop so check CD-DCE eliminates one loop instead. */ -/* { dg-final { scan-tree-dump "fix_loop_structure: removing loop" "cddce3" } } */ diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index a573b8349bea..d4b3734304dd 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -349,6 +349,9 @@ back_threader::find_paths_to_names (basic_block bb, bitmap interesting, unsigned overall_paths, back_threader_profitability &profit) { + if (m_visited_bbs.add (bb)) + return; + m_path.safe_push (bb); // Try to resolve the path without looking back. Avoid resolving paths @@ -374,8 +377,7 @@ back_threader::find_paths_to_names (basic_block bb, bitmap interesting, // Continue looking for ways to extend the path but limit the // search space along a branch else if ((overall_paths = overall_paths * EDGE_COUNT (bb->preds)) - <= (unsigned)param_max_jump_thread_paths - && !m_visited_bbs.add (bb)) + <= (unsigned)param_max_jump_thread_paths) { // For further greedy searching we want to remove interesting // names defined in BB but add ones on the PHI edges for the @@ -487,7 +489,6 @@ back_threader::find_paths_to_names (basic_block bb, bitmap interesting, backtracking we have to restore it. */ for (int j : new_imports) bitmap_clear_bit (m_imports, j); - m_visited_bbs.remove (bb); } else if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " FAIL: Search space limit %d reached.\n", @@ -495,6 +496,7 @@ back_threader::find_paths_to_names (basic_block bb, bitmap interesting, // Reset things to their original state. m_path.pop (); + m_visited_bbs.remove (bb); } // Search backwards from BB looking for paths where the final
