]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Increase auto-fdo profile scaling
authorJan Hubicka <jh@suse.cz>
Sun, 21 Sep 2025 14:52:18 +0000 (16:52 +0200)
committerJan Hubicka <jh@suse.cz>
Sun, 21 Sep 2025 14:53:22 +0000 (16:53 +0200)
Increase 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.

gcc/ChangeLog:

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

gcc/auto-profile.cc

index ce607a68d2ee5706105ecaa3f7a97e4708e17d7e..7d867de5bd9d3ee287b177584ed0f37b840c276b 100644 (file)
@@ -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