Hi,
this patch increases scaling factor for auto-fdo profiles.  I origianlly used
n_bits/2 which is also used by local guessing algorithm.  For local guessing
algorithm the main factor is to prevent inliner scaling up the profile till
overflow.

With sane IPA profile large scaling up should essentially never happen. Inliner 
and
ipa-cp only duplicates code and should only scale down. ipa-icf and tail 
merging merges
code but not very large number of code paths.
In practice scaling up still happens when profile is inconsisent, so this use
n_bits-10, which is 50 currently.  The main advantage of this is to reduce 
chances
things drop to 0 and we hit the various special cases for 0 auto-FDO profile.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

        * auto-profile.cc (autofdo_source_profile::read): Scale profile up to
        profile_count::n_bits - 10.

diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
index ce607a68d2e..7d867de5bd9 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -2627,7 +2627,7 @@ autofdo_source_profile::read ()
      bigger than sum_max eventually.  */
   if (afdo_profile_info->sum_max)
     afdo_count_scale
-      = MAX (((gcov_type)1 << (profile_count::n_bits / 2))
+      = MAX (((gcov_type)1 << (profile_count::n_bits - 10))
             / afdo_profile_info->sum_max, 1);
   afdo_profile_info->cutoff *= afdo_count_scale;
   afdo_hot_bb_threshod

Reply via email to