https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124383
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Component|target |rtl-optimization
Last reconfirmed| |2026-03-06
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
Something like this:
diff --git a/gcc/bb-reorder.cc b/gcc/bb-reorder.cc
index 4e863bdac99..18d7175972d 100644
--- a/gcc/bb-reorder.cc
+++ b/gcc/bb-reorder.cc
@@ -1666,7 +1666,11 @@ find_rarely_executed_basic_blocks_and_crossing_edges
(void)
{
bool cold_bb = false;
- if (probably_never_executed_bb_p (cfun, bb))
+ /* A basic block isn't cold if it only has one predecessor which
+ isn't cold. */
+ if (probably_never_executed_bb_p (cfun, bb)
+ && (!single_pred_p (bb)
+ || probably_never_executed_bb_p (cfun, single_pred (bb))))
{
cold_bb = true;