]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Propagate unlikely executed BBs even on measured profiles
authorJan Hubicka <hubicka@ucw.cz>
Wed, 1 Oct 2025 14:51:26 +0000 (16:51 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Wed, 1 Oct 2025 14:51:26 +0000 (16:51 +0200)
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.

gcc/predict.cc

index 5639d81d2770c9adec3c943ceb8423e6ba4b33f3..895c5f959d02f1c8dedcf61e9c69c1f0fab70d83 100644 (file)
@@ -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;"