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.h | |
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.h')
-rw-r--r-- | gcc/profile-count.h | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/gcc/profile-count.h b/gcc/profile-count.h index 234e388..c83fa3b 100644 --- a/gcc/profile-count.h +++ b/gcc/profile-count.h @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #define GCC_PROFILE_COUNT_H struct function; +class profile_count; /* Quality of the profile count. Because gengtype does not support enums inside of classes, this is in global namespace. */ @@ -350,7 +351,7 @@ public: return profile_probability::uninitialized (); profile_probability ret; ret.m_val = RDIV ((uint64_t)m_val * other.m_val, max_probability); - ret.m_quality = MIN (m_quality, other.m_quality); + ret.m_quality = MIN (MIN (m_quality, other.m_quality), profile_adjusted); return ret; } profile_probability &operator*= (const profile_probability &other) @@ -363,7 +364,7 @@ public: else { m_val = RDIV ((uint64_t)m_val * other.m_val, max_probability); - m_quality = MIN (m_quality, other.m_quality); + m_quality = MIN (MIN (m_quality, other.m_quality), profile_adjusted); } return *this; } @@ -374,8 +375,14 @@ public: if (!initialized_p () || !other.initialized_p ()) return profile_probability::uninitialized (); profile_probability ret; + /* If we get probability above 1, mark it as unreliable and return 1. */ if (m_val >= other.m_val) - ret.m_val = max_probability; + { + ret.m_val = max_probability; + ret.m_quality = MIN (MIN (m_quality, other.m_quality), + profile_guessed); + return ret; + } else if (!m_val) ret.m_val = 0; else @@ -385,7 +392,7 @@ public: other.m_val), max_probability); } - ret.m_quality = MIN (m_quality, other.m_quality); + ret.m_quality = MIN (MIN (m_quality, other.m_quality), profile_adjusted); return ret; } profile_probability &operator/= (const profile_probability &other) @@ -396,8 +403,15 @@ public: return *this = profile_probability::uninitialized (); else { + /* If we get probability above 1, mark it as unreliable + and return 1. */ if (m_val > other.m_val) - m_val = max_probability; + { + m_val = max_probability; + m_quality = MIN (MIN (m_quality, other.m_quality), + profile_guessed); + return *this; + } else if (!m_val) ; else @@ -407,7 +421,7 @@ public: other.m_val), max_probability); } - m_quality = MIN (m_quality, other.m_quality); + m_quality = MIN (MIN (m_quality, other.m_quality), profile_adjusted); } return *this; } @@ -465,27 +479,6 @@ public: return ret; } - profile_probability combine_with_freq (int freq1, profile_probability other, - int freq2) const - { - profile_probability ret; - - if (*this == profile_probability::uninitialized () - || other == profile_probability::uninitialized ()) - return profile_probability::uninitialized (); - - gcc_checking_assert (freq1 >= 0 && freq2 >= 0); - if (!freq1 && !freq2) - { - ret.m_val = (m_val + other.m_val) / 2; - } - else - ret.m_val = RDIV (m_val * (uint64_t) freq1 - + other.m_val * (uint64_t) freq2, freq1 + freq2); - ret.m_quality = MIN (m_quality, other.m_quality); - return ret; - } - /* Return *THIS * NUM / DEN. */ profile_probability apply_scale (int64_t num, int64_t den) const { @@ -569,6 +562,12 @@ public: bool differs_from_p (profile_probability other) const; /* Return if difference is greater than 50%. */ bool differs_lot_from_p (profile_probability other) const; + /* COUNT1 times event happens with *THIS probability, COUNT2 times OTHER + happens with COUNT2 probablity. Return probablity that either *THIS or + OTHER happens. */ + profile_probability combine_with_count (profile_count count1, + profile_probability other, + profile_count count2) const; /* LTO streaming support. */ static profile_probability stream_in (struct lto_input_block *); @@ -906,7 +905,10 @@ public: return *this; profile_count ret = *this; if (ret.m_val == 0) - ret.m_val = 1; + { + ret.m_val = 1; + ret.m_quality = MIN (m_quality, profile_adjusted); + } return ret; } @@ -1062,20 +1064,28 @@ public: OVERALL. */ profile_probability probability_in (const profile_count overall) const { - if (*this == profile_count::zero ()) + if (*this == profile_count::zero () + && !(overall == profile_count::zero ())) return profile_probability::never (); if (!initialized_p () || !overall.initialized_p () || !overall.m_val) return profile_probability::uninitialized (); + if (*this == overall && m_quality == profile_precise) + return profile_probability::always (); profile_probability ret; gcc_checking_assert (compatible_p (overall)); if (overall.m_val < m_val) - ret.m_val = profile_probability::max_probability; + { + ret.m_val = profile_probability::max_probability; + ret.m_quality = profile_guessed; + return ret; + } else ret.m_val = RDIV (m_val * profile_probability::max_probability, overall.m_val); - ret.m_quality = MAX (MIN (m_quality, overall.m_quality), profile_guessed); + ret.m_quality = MIN (MAX (MIN (m_quality, overall.m_quality), + profile_guessed), profile_adjusted); return ret; } |