From a4c3f08dadad805010c2411e79d80d023693a1b0 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 20 May 2019 09:53:31 +0200 Subject: [PATCH] Do not use full qualified names if possible. 2019-05-20 Martin Liska * profile-count.h: Do not use full qualified names if possible. * profile-count.c (profile_count::to_frequency): Likewise. From-SVN: r271398 --- gcc/ChangeLog | 6 ++ gcc/profile-count.c | 15 ++--- gcc/profile-count.h | 155 ++++++++++++++++++++++---------------------- 3 files changed, 89 insertions(+), 87 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9f423ee30fe..b117803c522 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-05-20 Martin Liska + + * profile-count.h: Do not use full qualified + names if possible. + * profile-count.c (profile_count::to_frequency): Likewise. + 2019-05-20 Martin Liska * profile-count.h (enum profile_quality): Use capital letters diff --git a/gcc/profile-count.c b/gcc/profile-count.c index 21c85290d84..010b18c0aa5 100644 --- a/gcc/profile-count.c +++ b/gcc/profile-count.c @@ -268,7 +268,7 @@ profile_count::to_frequency (struct function *fun) const { if (!initialized_p ()) return BB_FREQ_MAX; - if (*this == profile_count::zero ()) + if (*this == zero ()) return 0; gcc_assert (REG_BR_PROB_BASE == BB_FREQ_MAX && fun->cfg->count_max.initialized_p ()); @@ -287,7 +287,7 @@ profile_count::to_cgraph_frequency (profile_count entry_bb_count) const { if (!initialized_p () || !entry_bb_count.initialized_p ()) return CGRAPH_FREQ_BASE; - if (*this == profile_count::zero ()) + if (*this == zero ()) return 0; gcc_checking_assert (entry_bb_count.initialized_p ()); uint64_t scale; @@ -310,7 +310,7 @@ profile_count::to_sreal_scale (profile_count in, bool *known) const } if (known) *known = true; - if (*this == profile_count::zero ()) + if (*this == zero ()) return 0; if (!in.m_val) @@ -337,7 +337,7 @@ profile_count::adjust_for_ipa_scaling (profile_count *num, if (*num == *den) return; /* Scaling to zero is always zero. */ - if (*num == profile_count::zero ()) + if (*num == zero ()) return; /* If den is non-zero we are safe. */ if (den->force_nonzero () == *den) @@ -359,9 +359,9 @@ profile_count::combine_with_ipa_count (profile_count ipa) ipa = ipa.ipa (); if (ipa.nonzero_p ()) return ipa; - if (!ipa.initialized_p () || *this == profile_count::zero ()) + if (!ipa.initialized_p () || *this == zero ()) return *this; - if (ipa == profile_count::zero ()) + if (ipa == zero ()) return this->global0 (); return this->global0adjusted (); } @@ -406,6 +406,5 @@ profile_probability::combine_with_count (profile_count count1, return *this * count1.probability_in (count1 + count2) + other * count2.probability_in (count1 + count2); else - return *this * profile_probability::even () - + other * profile_probability::even (); + return *this * even () + other * even (); } diff --git a/gcc/profile-count.h b/gcc/profile-count.h index 715e2586bb0..a6d91321470 100644 --- a/gcc/profile-count.h +++ b/gcc/profile-count.h @@ -177,30 +177,28 @@ public: static profile_probability very_unlikely () { /* Be consistent with PROB_VERY_UNLIKELY in predict.h. */ - profile_probability r - = profile_probability::guessed_always ().apply_scale (1, 2000); + profile_probability r = guessed_always ().apply_scale (1, 2000); r.m_val--; return r; } static profile_probability unlikely () { /* Be consistent with PROB_VERY_LIKELY in predict.h. */ - profile_probability r - = profile_probability::guessed_always ().apply_scale (1, 5); + profile_probability r = guessed_always ().apply_scale (1, 5); r.m_val--; return r; } static profile_probability even () { - return profile_probability::guessed_always ().apply_scale (1, 2); + return guessed_always ().apply_scale (1, 2); } static profile_probability very_likely () { - return profile_probability::always () - very_unlikely (); + return always () - very_unlikely (); } static profile_probability likely () { - return profile_probability::always () - unlikely (); + return always () - unlikely (); } static profile_probability guessed_always () { @@ -266,8 +264,7 @@ public: { gcc_checking_assert (initialized_p ()); int ret = m_val * 8 + m_quality; - gcc_checking_assert (profile_probability::from_reg_br_prob_note (ret) - == *this); + gcc_checking_assert (from_reg_br_prob_note (ret) == *this); return ret; } @@ -297,12 +294,12 @@ public: } profile_probability operator+ (const profile_probability &other) const { - if (other == profile_probability::never ()) + if (other == never ()) return *this; - if (*this == profile_probability::never ()) + if (*this == never ()) return other; if (!initialized_p () || !other.initialized_p ()) - return profile_probability::uninitialized (); + return uninitialized (); profile_probability ret; ret.m_val = MIN ((uint32_t)(m_val + other.m_val), max_probability); @@ -311,15 +308,15 @@ public: } profile_probability &operator+= (const profile_probability &other) { - if (other == profile_probability::never ()) + if (other == never ()) return *this; - if (*this == profile_probability::never ()) + if (*this == never ()) { *this = other; return *this; } if (!initialized_p () || !other.initialized_p ()) - return *this = profile_probability::uninitialized (); + return *this = uninitialized (); else { m_val = MIN ((uint32_t)(m_val + other.m_val), max_probability); @@ -329,11 +326,11 @@ public: } profile_probability operator- (const profile_probability &other) const { - if (*this == profile_probability::never () - || other == profile_probability::never ()) + if (*this == never () + || other == never ()) return *this; if (!initialized_p () || !other.initialized_p ()) - return profile_probability::uninitialized (); + return uninitialized (); profile_probability ret; ret.m_val = m_val >= other.m_val ? m_val - other.m_val : 0; ret.m_quality = MIN (m_quality, other.m_quality); @@ -341,11 +338,11 @@ public: } profile_probability &operator-= (const profile_probability &other) { - if (*this == profile_probability::never () - || other == profile_probability::never ()) + if (*this == never () + || other == never ()) return *this; if (!initialized_p () || !other.initialized_p ()) - return *this = profile_probability::uninitialized (); + return *this = uninitialized (); else { m_val = m_val >= other.m_val ? m_val - other.m_val : 0; @@ -355,11 +352,11 @@ public: } profile_probability operator* (const profile_probability &other) const { - if (*this == profile_probability::never () - || other == profile_probability::never ()) - return profile_probability::never (); + if (*this == never () + || other == never ()) + return never (); if (!initialized_p () || !other.initialized_p ()) - return profile_probability::uninitialized (); + return uninitialized (); profile_probability ret; ret.m_val = RDIV ((uint64_t)m_val * other.m_val, max_probability); ret.m_quality = MIN (MIN (m_quality, other.m_quality), ADJUSTED); @@ -367,11 +364,11 @@ public: } profile_probability &operator*= (const profile_probability &other) { - if (*this == profile_probability::never () - || other == profile_probability::never ()) - return *this = profile_probability::never (); + if (*this == never () + || other == never ()) + return *this = never (); if (!initialized_p () || !other.initialized_p ()) - return *this = profile_probability::uninitialized (); + return *this = uninitialized (); else { m_val = RDIV ((uint64_t)m_val * other.m_val, max_probability); @@ -381,10 +378,10 @@ public: } profile_probability operator/ (const profile_probability &other) const { - if (*this == profile_probability::never ()) - return profile_probability::never (); + if (*this == never ()) + return never (); if (!initialized_p () || !other.initialized_p ()) - return profile_probability::uninitialized (); + return uninitialized (); profile_probability ret; /* If we get probability above 1, mark it as unreliable and return 1. */ if (m_val >= other.m_val) @@ -408,10 +405,10 @@ public: } profile_probability &operator/= (const profile_probability &other) { - if (*this == profile_probability::never ()) - return *this = profile_probability::never (); + if (*this == never ()) + return *this = never (); if (!initialized_p () || !other.initialized_p ()) - return *this = profile_probability::uninitialized (); + return *this = uninitialized (); else { /* If we get probability above 1, mark it as unreliable @@ -460,14 +457,14 @@ public: Avoid scaling when overall outcome is supposed to be always. Without knowing that one is inverse of toher, the result would be conservative. */ - if (!(*this == profile_probability::always ())) + if (!(*this == always ())) *this = (*this - ret) / ret.invert (); return ret; } gcov_type apply (gcov_type val) const { - if (*this == profile_probability::uninitialized ()) + if (*this == uninitialized ()) return val / 2; return RDIV (val * m_val, max_probability); } @@ -475,7 +472,7 @@ public: /* Return 1-*THIS. */ profile_probability invert () const { - return profile_probability::always() - *this; + return always() - *this; } /* Return THIS with quality dropped to GUESSED. */ @@ -497,10 +494,10 @@ public: /* Return *THIS * NUM / DEN. */ profile_probability apply_scale (int64_t num, int64_t den) const { - if (*this == profile_probability::never ()) + if (*this == never ()) return *this; if (!initialized_p ()) - return profile_probability::uninitialized (); + return uninitialized (); profile_probability ret; uint64_t tmp; safe_scale_64bit (m_val, num, den, &tmp); @@ -684,8 +681,8 @@ private: { if (!initialized_p () || !other.initialized_p ()) return true; - if (*this == profile_count::zero () - || other == profile_count::zero ()) + if (*this == zero () + || other == zero ()) return true; return ipa_p () == other.ipa_p (); } @@ -789,12 +786,12 @@ public: } profile_count operator+ (const profile_count &other) const { - if (other == profile_count::zero ()) + if (other == zero ()) return *this; - if (*this == profile_count::zero ()) + if (*this == zero ()) return other; if (!initialized_p () || !other.initialized_p ()) - return profile_count::uninitialized (); + return uninitialized (); profile_count ret; gcc_checking_assert (compatible_p (other)); @@ -804,15 +801,15 @@ public: } profile_count &operator+= (const profile_count &other) { - if (other == profile_count::zero ()) + if (other == zero ()) return *this; - if (*this == profile_count::zero ()) + if (*this == zero ()) { *this = other; return *this; } if (!initialized_p () || !other.initialized_p ()) - return *this = profile_count::uninitialized (); + return *this = uninitialized (); else { gcc_checking_assert (compatible_p (other)); @@ -823,10 +820,10 @@ public: } profile_count operator- (const profile_count &other) const { - if (*this == profile_count::zero () || other == profile_count::zero ()) + if (*this == zero () || other == zero ()) return *this; if (!initialized_p () || !other.initialized_p ()) - return profile_count::uninitialized (); + return uninitialized (); gcc_checking_assert (compatible_p (other)); profile_count ret; ret.m_val = m_val >= other.m_val ? m_val - other.m_val : 0; @@ -835,10 +832,10 @@ public: } profile_count &operator-= (const profile_count &other) { - if (*this == profile_count::zero () || other == profile_count::zero ()) + if (*this == zero () || other == zero ()) return *this; if (!initialized_p () || !other.initialized_p ()) - return *this = profile_count::uninitialized (); + return *this = uninitialized (); else { gcc_checking_assert (compatible_p (other)); @@ -861,9 +858,9 @@ public: { if (!initialized_p () || !other.initialized_p ()) return false; - if (*this == profile_count::zero ()) - return !(other == profile_count::zero ()); - if (other == profile_count::zero ()) + if (*this == zero ()) + return !(other == zero ()); + if (other == zero ()) return false; gcc_checking_assert (compatible_p (other)); return m_val < other.m_val; @@ -872,10 +869,10 @@ public: { if (!initialized_p () || !other.initialized_p ()) return false; - if (*this == profile_count::zero ()) + if (*this == zero ()) return false; - if (other == profile_count::zero ()) - return !(*this == profile_count::zero ()); + if (other == zero ()) + return !(*this == zero ()); gcc_checking_assert (compatible_p (other)); return initialized_p () && other.initialized_p () && m_val > other.m_val; } @@ -896,10 +893,10 @@ public: { if (!initialized_p () || !other.initialized_p ()) return false; - if (*this == profile_count::zero ()) + if (*this == zero ()) return true; - if (other == profile_count::zero ()) - return (*this == profile_count::zero ()); + if (other == zero ()) + return (*this == zero ()); gcc_checking_assert (compatible_p (other)); return m_val <= other.m_val; } @@ -907,10 +904,10 @@ public: { if (!initialized_p () || !other.initialized_p ()) return false; - if (other == profile_count::zero ()) + if (other == zero ()) return true; - if (*this == profile_count::zero ()) - return (other == profile_count::zero ()); + if (*this == zero ()) + return (other == zero ()); gcc_checking_assert (compatible_p (other)); return m_val >= other.m_val; } @@ -954,9 +951,9 @@ public: return other; if (!other.initialized_p ()) return *this; - if (*this == profile_count::zero ()) + if (*this == zero ()) return other; - if (other == profile_count::zero ()) + if (other == zero ()) return *this; gcc_checking_assert (compatible_p (other)); if (m_val < other.m_val || (m_val == other.m_val @@ -973,7 +970,7 @@ public: if (m_val == 0) return *this; if (!initialized_p ()) - return profile_count::uninitialized (); + return uninitialized (); profile_count ret; ret.m_val = RDIV (m_val * prob, REG_BR_PROB_BASE); ret.m_quality = MIN (m_quality, ADJUSTED); @@ -983,12 +980,12 @@ public: /* Scale counter according to PROB. */ profile_count apply_probability (profile_probability prob) const { - if (*this == profile_count::zero ()) + if (*this == zero ()) return *this; if (prob == profile_probability::never ()) - return profile_count::zero (); + return zero (); if (!initialized_p ()) - return profile_count::uninitialized (); + return uninitialized (); profile_count ret; uint64_t tmp; safe_scale_64bit (m_val, prob.m_val, profile_probability::max_probability, @@ -1003,7 +1000,7 @@ public: if (m_val == 0) return *this; if (!initialized_p ()) - return profile_count::uninitialized (); + return uninitialized (); profile_count ret; uint64_t tmp; @@ -1015,12 +1012,12 @@ public: } profile_count apply_scale (profile_count num, profile_count den) const { - if (*this == profile_count::zero ()) + if (*this == zero ()) return *this; - if (num == profile_count::zero ()) + if (num == zero ()) return num; if (!initialized_p () || !num.initialized_p () || !den.initialized_p ()) - return profile_count::uninitialized (); + return uninitialized (); if (num == den) return *this; gcc_checking_assert (den.m_val); @@ -1082,10 +1079,10 @@ public: if (m_quality > GUESSED_GLOBAL0_ADJUSTED) return *this; if (m_quality == GUESSED_GLOBAL0) - return profile_count::zero (); + return zero (); if (m_quality == GUESSED_GLOBAL0_ADJUSTED) - return profile_count::adjusted_zero (); - return profile_count::uninitialized (); + return adjusted_zero (); + return uninitialized (); } /* Return THIS with quality dropped to AFDO. */ @@ -1100,8 +1097,8 @@ public: OVERALL. */ profile_probability probability_in (const profile_count overall) const { - if (*this == profile_count::zero () - && !(overall == profile_count::zero ())) + if (*this == zero () + && !(overall == zero ())) return profile_probability::never (); if (!initialized_p () || !overall.initialized_p () || !overall.m_val) -- 2.30.2