https://gcc.gnu.org/g:bae9c5e7c6efc0cbed9ea98c4c58bf7ed341f68d

commit r16-4164-gbae9c5e7c6efc0cbed9ea98c4c58bf7ed341f68d
Author: Jan Hubicka <[email protected]>
Date:   Wed Oct 1 16:51:26 2025 +0200

    Propagate unlikely executed BBs even on measured profiles
    
    While looking into AutoFDO porfiles I noticed that sometimes we lost
    precise zero counts due to inlining and merging basic blocks.  Propagating
    precise zero counts should be safe even for measured profiles and thus
    this patch enables it.
    
    gcc/ChangeLog:
    
            * predict.cc (unlikely_executed_stmt_p): Remove redundant check.
            (rebuild_frequencies): Also recompute unlikely bbs when profile is
            present or consistent.

Diff:
---
 gcc/predict.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/predict.cc b/gcc/predict.cc
index 5639d81d2770..895c5f959d02 100644
--- a/gcc/predict.cc
+++ b/gcc/predict.cc
@@ -852,7 +852,7 @@ unlikely_executed_stmt_p (gimple *stmt)
      heuristics.  */
   if (gimple_bb (stmt)->count.reliable_p ()
       && gimple_bb (stmt)->count.nonzero_p ())
-    return gimple_bb (stmt)->count == profile_count::zero ();
+    return false;
   /* NORETURN attribute alone is not strong enough: exit() may be quite
      likely executed once during program run.  */
   if (gimple_call_fntype (stmt)
@@ -4521,6 +4521,9 @@ rebuild_frequencies (void)
       && (!uninitialized_count_found || uninitialized_probablity_found)
       && !cfun->cfg->count_max.very_large_p ())
     {
+      /* Propagating zero counts should be safe and may
+        help hot/cold splitting.  */
+      determine_unlikely_bbs ();
       if (dump_file)
        fprintf (dump_file, "Profile is consistent\n");
       return;
@@ -4545,6 +4548,9 @@ rebuild_frequencies (void)
      for a given run, we would only propagate the error further.  */
   if (feedback_found && !uninitialized_count_found)
     {
+      /* Propagating zero counts should be safe and may
+        help hot/cold splitting.  */
+      determine_unlikely_bbs ();
       if (dump_file)
        fprintf (dump_file,
            "Profile is inconsistent but read from profile feedback;"

Reply via email to