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

commit r16-4011-gd74aec06b106e0c42e3210bddeb02a5512f4d382
Author: Jan Hubicka <[email protected]>
Date:   Sun Sep 21 19:51:57 2025 +0200

    One extra special case for AFDO0
    
    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.

Diff:
---
 gcc/cgraph.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index e5902a0fdcd0..72e6f54536d4 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -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

Reply via email to