From d74aec06b106e0c42e3210bddeb02a5512f4d382 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sun, 21 Sep 2025 19:51:57 +0200 Subject: [PATCH] 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. --- gcc/cgraph.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index e5902a0fdcd..72e6f54536d 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 -- 2.47.3