From 9766f99e6ea365c6ff2c4b1a27a8b9eddb323eb1 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sun, 21 Sep 2025 16:52:18 +0200 Subject: [PATCH] Increase auto-fdo profile scaling 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.47.3