]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cfgcleanup: forwarder block, ignore bbs which merge with the predecessor
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 12 Nov 2025 00:47:04 +0000 (16:47 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Thu, 13 Nov 2025 20:56:52 +0000 (12:56 -0800)
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 <andrew.pinski@oss.qualcomm.com>
gcc/tree-cfgcleanup.cc

index 9f526492b720c07c893086731caca3d5fb1ce4e3..cc0838d8c4c789239dec7442c480d44afe551389 100644 (file)
@@ -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,