diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2018-01-24 09:12:40 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2018-01-24 08:12:40 +0000 |
commit | 97c07987a6d8052c77125b5f9841abc1f937b3eb (patch) | |
tree | 660c3f17e8e166b824b72c77a9eb809b2f20310e /gcc/profile-count.c | |
parent | 3885527ddf9ea47d0eab8d2c3a503a8e8e01d97d (diff) | |
download | gcc-97c07987a6d8052c77125b5f9841abc1f937b3eb.zip gcc-97c07987a6d8052c77125b5f9841abc1f937b3eb.tar.gz gcc-97c07987a6d8052c77125b5f9841abc1f937b3eb.tar.bz2 |
cfgcleanup.c (try_crossjump_to_edge): Use combine_with_count to merge probabilities.
* cfgcleanup.c (try_crossjump_to_edge): Use combine_with_count
to merge probabilities.
* predict.c (probably_never_executed): Also mark as cold functions
with global 0 profile and guessed local profile.
* profile-count.c (profile_probability::combine_with_count): New
member function.
* profile-count.h (profile_probability::operator*,
profile_probability::operator*=, profile_probability::operator/,
profile_probability::operator/=): Reduce precision to adjusted
and set value to guessed on contradictory divisions.
(profile_probability::combine_with_freq): Remove.
(profile_probability::combine_wiht_count): Declare.
(profile_count::force_nonzero):: Set to adjusted.
(profile_count::probability_in):: Set quality to adjusted.
* tree-ssa-tail-merge.c (replace_block_by): Use
combine_with_count.
From-SVN: r257010
Diffstat (limited to 'gcc/profile-count.c')
-rw-r--r-- | gcc/profile-count.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/profile-count.c b/gcc/profile-count.c index 5f1a5fb..c3b115f 100644 --- a/gcc/profile-count.c +++ b/gcc/profile-count.c @@ -345,3 +345,29 @@ profile_count::from_gcov_type (gcov_type v) return ret; } + +/* COUNT1 times event happens with *THIS probability, COUNT2 times OTHER + happens with COUNT2 probablity. Return probablity that either *THIS or + OTHER happens. */ + +profile_probability +profile_probability::combine_with_count (profile_count count1, + profile_probability other, + profile_count count2) const +{ + /* If probabilities are same, we are done. + If counts are nonzero we can distribute accordingly. In remaining + cases just avreage the values and hope for the best. */ + if (*this == other || count1 == count2 + || (count2 == profile_count::zero () + && !(count1 == profile_count::zero ()))) + return *this; + if (count1 == profile_count::zero () && !(count2 == profile_count::zero ())) + return other; + else if (count1.nonzero_p () || count2.nonzero_p ()) + return *this * count1.probability_in (count1 + count2) + + other * count2.probability_in (count1 + count2); + else + return *this * profile_probability::even () + + other * profile_probability::even (); +} |