]> git.ipfire.org Git - thirdparty/gcc.git/commit
updat_bb_profile_for_threading TLC
authorJan Hubicka <jh@suse.cz>
Thu, 6 Jul 2023 14:19:15 +0000 (16:19 +0200)
committerJan Hubicka <jh@suse.cz>
Thu, 6 Jul 2023 14:19:15 +0000 (16:19 +0200)
commit2e406f0753e8d78d320437189211e3094c33b7e4
treec15b533195aa6e82aeb3ae7c25e94ace20609244
parentb74e4cabd5984b742dbe32ba246b0d618bc30dd8
updat_bb_profile_for_threading TLC

Apply some TLC to update_bb_profile_for_threading.  The function resales
probabilities by:
       FOR_EACH_EDGE (c, ei, bb->succs)
  c->probability /= prob;
which is correct but in case prob is 0 (took all execution counts to the newly
constructed path), this leads to undefined results which do not sum to 100%.

In several other plpaces we need to change probability of one edge and rescale
remaining to sum to 100% so I decided to break this off to helper function
set_edge_probability_and_rescale_others

For jump threading the probability of edge is always reduced, so division is right
update, however in general case we also may want to increase probability of the edge
which needs different scalling.  This is bit hard to do staying with probabilities
in range 0...1 for all temporaries.

For this reason I decided to add profile_probability::apply_scale which is symmetric
to what we already have in profile_count::apply_scale and does right thing in
both directions.

Finally I added few early exits so we do not produce confused dumps when
profile is missing and special case the common situation where edges out of BB
are precisely two.  In this case we can set the other edge to inverter probability
which. Saling drop probability quality from PRECISE to ADJUSTED.

Bootstrapped/regtested x86_64-linux. The patch has no effect on in count mismatches
in tramp3d build and improves out-count.  Will commit it shortly.

gcc/ChangeLog:

* cfg.cc (set_edge_probability_and_rescale_others): New function.
(update_bb_profile_for_threading): Use it; simplify the rest.
* cfg.h (set_edge_probability_and_rescale_others): Declare.
* profile-count.h (profile_probability::apply_scale): New.
gcc/cfg.cc
gcc/cfg.h
gcc/profile-count.h