Hi, 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.
Bootstrapped/regtesed x86_64-linux. Comitted. gcc/ChangeLog: * cgraph.cc (cgraph_edge::maybe_hot_p): For AFDO profiles force count to be non-zero. 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