https://gcc.gnu.org/g:40c037adb367f9ab8ead1be2e4142a8447f22d13

commit r16-5252-g40c037adb367f9ab8ead1be2e4142a8447f22d13
Author: Andrew Pinski <[email protected]>
Date:   Tue Nov 11 16:47:04 2025 -0800

    cfgcleanup: forwarder block, ignore bbs which merge with the predecessor
    
    While moving mergephi's forwarder block removal over to cfgcleanup,
    I noticed a few regressions due to removal of a forwarder block (correctly)
    but the counts were not updated, instead let these blocks be handled by the 
merge_blocks
    cleanup code.
    
    gcc/ChangeLog:
    
            * tree-cfgcleanup.cc (tree_forwarder_block_p): Reject bb which has 
a single
            predecessor which has a single successor.
    
    Signed-off-by: Andrew Pinski <[email protected]>

Diff:
---
 gcc/tree-cfgcleanup.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc
index 9f526492b720..cc0838d8c4c7 100644
--- a/gcc/tree-cfgcleanup.cc
+++ b/gcc/tree-cfgcleanup.cc
@@ -425,6 +425,13 @@ tree_forwarder_block_p (basic_block bb, bool phi_wanted)
        return false;
   }
 
+  /* If this bb has a single predecessor and that predecssor
+     has a single successor, this bb will be merged with the
+     predecessor so ignore it for removing of the forwarder block. */
+  if (single_pred_p (bb)
+      && single_succ_p (single_pred_edge (bb)->src))
+    return false;
+
   basic_block dest = single_succ_edge (bb)->dest;
 
   /* Now walk through the statements backward.  We can ignore labels,

Reply via email to