]> git.ipfire.org Git - thirdparty/gcc.git/commit
Cleanup max of profile_count
authorJan Hubicka <hubicka@ucw.cz>
Wed, 15 Oct 2025 07:49:21 +0000 (09:49 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Wed, 15 Oct 2025 07:55:17 +0000 (09:55 +0200)
commita93f80feeef744649dc426a59a5860224d13e68d
tree2753941c48f3e93e7d22f03c408dbd3e07766673
parent24cc91f5ca8956bfc12a7533b665d9830846110a
Cleanup max of profile_count

profile_count::max is not implemented same way as other arithmetics on
profile counts which generally require counts to be compatible and
returns minimum of qualities of input counts.  Reason is that originally
it was used to compute statistics of whole callgraph profile so inliner
weights can be scaled to reasonable integers interprocedurally.  It also
combines qulities weird way so the same counter could be used to
determine what quality of profile is available.  That code had roundoff
error issues and was replaced by sreals.

Now max is mostly used to determine cfg->max_count which is used to
scale counts to reasonable integers intraprocedurally and is still being
used i.e. by IRA.  There are also few places where max is used for
normal arithmetics when updating profile.

For computing max_count we need max to still be a bit special so max
(uninitialized, initialized) returns initialized rather then
uninitialized. Partial profiles are later handled specially.

This patch renames max to max_prefer_initialized to make it clear and updates
implementation to require compatible profiles.  I checked this behaviour is good
for other places using it as well.
I also turned function to static, since a = a->max (b) looks odd.

gcc/ChangeLog:

* auto-profile.cc (scale_bb_profile): Use
profile_count::max_prefer_initialized.
(afdo_adjust_guessed_profile): Likewise.
* bb-reorder.cc (edge_order): Do not use max.
* cfghooks.cc (merge_blocks): Likewise.
* ipa-fnsummary.cc (param_change_prob): Likewise.
* ipa-inline-transform.cc (inline_transform): Likewise.
* predict.cc (update_max_bb_count): Likewise.
(estimate_bb_frequencies): Likewise.
(rebuild_frequencies): Likewise.
* tree-ssa-loop-unswitch.cc (struct unswitch_predicate): Likewise.
* profile-count.h (profile_count::max): Rename to
(profile_count::max_prefer_initialized): this; update handling
of qualities.
gcc/auto-profile.cc
gcc/bb-reorder.cc
gcc/cfghooks.cc
gcc/ipa-fnsummary.cc
gcc/ipa-inline-transform.cc
gcc/predict.cc
gcc/profile-count.h
gcc/tree-ssa-loop-unswitch.cc