aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2017-06-22 16:50:23 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2017-06-22 14:50:23 +0000
commiteaee472d05fea91e1dde0bb9347d179ebf1aafa3 (patch)
tree6c8ca0f5e51138f355d7e078ec444df14c9deb30
parentc016fd32fe7da1a8c97f96f7e9767e4e300b3d28 (diff)
downloadgcc-eaee472d05fea91e1dde0bb9347d179ebf1aafa3.zip
gcc-eaee472d05fea91e1dde0bb9347d179ebf1aafa3.tar.gz
gcc-eaee472d05fea91e1dde0bb9347d179ebf1aafa3.tar.bz2
profile-count.h (apply_probability, [...]): Fix checks for zero.
* profile-count.h (apply_probability, apply_scale, probability_in): Fix checks for zero. From-SVN: r249563
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/profile-count.h19
2 files changed, 15 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a2340c0..0a3426e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2017-06-22 Jan Hubicka <hubicka@ucw.cz>
+
+ * profile-count.h (apply_probability,
+ apply_scale, probability_in): Fix checks for zero.
+
2017-06-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* incpath.c (add_sysroot_to_chain): Allow for $SYSROOT prefix.
diff --git a/gcc/profile-count.h b/gcc/profile-count.h
index 42509c4..0f77e4e 100644
--- a/gcc/profile-count.h
+++ b/gcc/profile-count.h
@@ -255,7 +255,7 @@ public:
profile_count apply_probability (int prob) const
{
gcc_checking_assert (prob >= 0 && prob <= REG_BR_PROB_BASE);
- if (*this == profile_count::zero ())
+ if (m_val == 0)
return *this;
if (!initialized_p ())
return profile_count::uninitialized ();
@@ -267,24 +267,25 @@ public:
/* Return *THIS * NUM / DEN. */
profile_count apply_scale (int64_t num, int64_t den) const
{
- if (*this == profile_count::zero ())
+ if (m_val == 0)
return *this;
if (!initialized_p ())
return profile_count::uninitialized ();
profile_count ret;
+ gcc_checking_assert (num >= 0 && den > 0);
/* FIXME: shrink wrapping violates this sanity check. */
- gcc_checking_assert ((num >= 0
- && (num <= REG_BR_PROB_BASE
- || den <= REG_BR_PROB_BASE)
- && den > 0) || 1);
+ gcc_checking_assert ((num <= REG_BR_PROB_BASE
+ || den <= REG_BR_PROB_BASE) || 1);
ret.m_val = RDIV (m_val * num, den);
ret.m_quality = MIN (m_quality, count_adjusted);
return ret;
}
profile_count apply_scale (profile_count num, profile_count den) const
{
- if (*this == profile_count::zero () || num == profile_count::zero ())
- return profile_count::zero ();
+ if (m_val == 0)
+ return *this;
+ if (num.m_val == 0)
+ return num;
if (!initialized_p () || !num.initialized_p () || !den.initialized_p ())
return profile_count::uninitialized ();
gcc_checking_assert (den > 0);
@@ -306,7 +307,7 @@ public:
OVERALL. */
int probability_in (profile_count overall)
{
- if (*this == profile_count::zero ())
+ if (!m_val)
return 0;
if (!initialized_p () || !overall.initialized_p ())
return REG_BR_PROB_BASE / 2;