]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
One extra special case for AFDO0
authorJan Hubicka <jh@suse.cz>
Sun, 21 Sep 2025 17:51:57 +0000 (19:51 +0200)
committerJan Hubicka <jh@suse.cz>
Sun, 21 Sep 2025 17:55:16 +0000 (19:55 +0200)
This patch makes inliner and ipa-cp to consider optimization interesting even
in scenarios where aufdo countis 0, but scaleis high enough to make optimization
worthwhile.

gcc/ChangeLog:

* cgraph.cc (cgraph_edge::maybe_hot_p): For AFDO profiles force
count to be non-zero.

gcc/cgraph.cc

index e5902a0fdcd0fbbe08911f368b15c4c03827b5bf..72e6f54536d40df5ec662977a3d2aad6e1485fbd 100644 (file)
@@ -3157,9 +3157,17 @@ cgraph_edge::maybe_hot_p (sreal scale)
 
   /* If reliable IPA count is available, just use it.  */
   profile_count c = count.ipa ();
-  if (c.reliable_p ())
+  if (c.reliable_p ()
+      || (c.quality () == AFDO && c.nonzero_p ()))
     return maybe_hot_count_p (NULL, c * scale);
 
+  /* In auto-FDO, count 0 may lead to hot code in case the
+     call is simply not called often enough to receive some samples.  */
+  if ((c.quality () == AFDO
+       || count.quality () == GUESSED_GLOBAL0_ADJUSTED)
+      && callee && callee->count.quality () == AFDO)
+    return maybe_hot_count_p (NULL, c.force_nonzero () * scale);
+
   /* See if we can determine hotness using caller frequency.  */
   if (caller->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
       || (callee