]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix handling of goto locuses and phi args in auto-profile
authorJan Hubicka <hubicka@ucw.cz>
Wed, 1 Oct 2025 15:18:44 +0000 (17:18 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Wed, 1 Oct 2025 15:18:44 +0000 (17:18 +0200)
commitaa214a9d6bda35b324a1e48ba1ae5aa80f5aaa07
tree5afff80f9d262679195145f845c0fa5cdce813ec
parentf77e2fbf8297c293d23bf60e0b04d4d56b6ddc24
Fix handling of goto locuses and phi args in auto-profile

afdo_set_bb_count had code that, only if no count was determined in the BB itself,
looked into its outgoing edges and tried to determine counts based on location of
phi args.  This is not quite correct, since value detemrined is the count of edge
which may be lower than count of BB.

This patchs moves the logic into afdo_unscaled_edge_count and extends it to
also use goto_locus.  BB profile is infered only if BB has single successor and
otherwise the edge counts are stored into correct location in
afdo_calculate_branch_prob.

gcc/ChangeLog:

* auto-profile.cc (afdo_unscaled_edge_count): New function based on
part of ...
(afdo_set_bb_count): ... this function; use it here.
(afdo_calculate_branch_prob): Try to determine edge counts using
phi args and goto locuses.
gcc/auto-profile.cc