Hi Kugan, On Tue, Sep 29 2026, Kugan Vivekanandarajah wrote: > Ping ?
can you please have a look at https://inbox.sourceware.org/gcc-patches/[email protected]/ and to what extent this will avoid (or aggravate=) the issues you are having? Thanks, Martin > > Thanks, > Kugan > >> On 4 Sep 2026, at 8:48 am, Kugan Vivekanandarajah <[email protected]> >> wrote: >> >> AutoFDO count scaling should provide arithmetic precision without changing >> optimization decisions. However, IPA-CP profitability and zero-count >> ratios retains the absolute, causing cloning and profile >> propagation decisions to vary with afdo_count_scale. >> >> In this patch: >> Use normalized call frequencies for AutoFDO IPA-CP profitability. Derive >> synthetic AutoFDO zero counts from the scaled profile cutoff and cap ratios >> at one. >> >> AutoFDO performance with the patch relative to without the patch: >> >> 706.stockfish_r +3.05% >> 707.ntest_r -0.70% >> 708.sqlite_r -0.76% >> 714.cpython_r +1.62% >> 727.cppcheck_r +0.72% >> 734.vpr_r +0.12% >> 735.gem5_r -2.07% >> 750.sealcrypto_r -2.36% >> 753.ns3_r -1.34% >> 760.rocksdb_r +5.62% >> 777.zstd_r +0.34% >> 709.cactus_r +2.78% >> 722.palm_r +0.03% >> 731.astcenc_r -0.60% >> 736.ocio_r -0.70% >> 737.gmsh_r -0.73% >> 748.flightdm_r +8.58% >> 749.fotonik3d_r +6.16% >> 765.roms_r -0.70% >> 766.femflow_r +17.97% >> 772.marian_r +14.44% >> 782.lbm_r -0.67% >> >> gcc/ChangeLog: >> >> * ipa-cp.cc (good_cloning_opportunity_p): Use normalized frequency >> for AutoFDO profitability. >> * profile-count.cc (profile_count::to_sreal_scale): Use the scaled >> cutoff for synthetic AutoFDO zero counts and cap the resulting ratio. >> >> Signed-off-by: Kugan Vivekanandarajah <[email protected]> >> --- >> gcc/ipa-cp.cc | 8 ++++++-- >> gcc/profile-count.cc | 2 +- >> 2 files changed, 7 insertions(+), 3 deletions(-) >> >> diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc >> index d0428d04684..4a8f2ff3432 100644 >> --- a/gcc/ipa-cp.cc >> +++ b/gcc/ipa-cp.cc >> @@ -3474,8 +3474,12 @@ good_cloning_opportunity_p (struct cgraph_node *node, >> sreal time_benefit, >> if (count_sum.nonzero_p ()) >> { >> profile_count saved_time = count_sum * time_benefit; >> - sreal evaluation = saved_time.to_sreal_scale (profile_count::one ()) >> - / size_cost; >> + sreal evaluation; >> + if (flag_auto_profile) >> + evaluation = (time_benefit * freq_sum * 1000) / size_cost; >> + else >> + evaluation = saved_time.to_sreal_scale (profile_count::one ()) >> + / size_cost; >> evaluation = incorporate_penalties (node, info, evaluation); >> >> if (dump_file && (dump_flags & TDF_DETAILS)) >> diff --git a/gcc/profile-count.cc b/gcc/profile-count.cc >> index 9be209efda2..450e2db6538 100644 >> --- a/gcc/profile-count.cc >> +++ b/gcc/profile-count.cc >> @@ -358,7 +358,7 @@ profile_count::to_sreal_scale (profile_count in, bool >> *known) const >> /* Auto-FDO 0 really just means that we have no samples. >> Treat it as small non-zero frequency. */ >> if (!m_val && quality () == AFDO) >> - return (sreal)1 / (sreal)in.m_val; >> + return MIN ((sreal) 1, force_nonzero ().to_sreal_scale (in)); >> return (sreal)m_val / (sreal)in.m_val; >> } >> >> -- >> 2.34.1 >>
