Fix profile_count::apply_probability
profile_count::apply_probability misses check for uninitialized probability which leads to completely random results on applying uninitialized probability to initialized scale. This can make difference when i.e. inlining -fno-guess-branch-probability function to -fguess-branch-probability one. gcc/ChangeLog: * profile-count.h (profile_count::apply_probability): Fix handling of uninitialized probabilities, optimize scaling by probability 1.
This commit is contained in:
parent
d1c072a1c3
commit
499b8079a6
1 changed files with 2 additions and 2 deletions
|
@ -1129,11 +1129,11 @@ public:
|
|||
/* Scale counter according to PROB. */
|
||||
profile_count apply_probability (profile_probability prob) const
|
||||
{
|
||||
if (*this == zero ())
|
||||
if (*this == zero () || prob == profile_probability::always ())
|
||||
return *this;
|
||||
if (prob == profile_probability::never ())
|
||||
return zero ();
|
||||
if (!initialized_p ())
|
||||
if (!initialized_p () || !prob.initialized_p ())
|
||||
return uninitialized ();
|
||||
profile_count ret;
|
||||
uint64_t tmp;
|
||||
|
|
Loading…
Add table
Reference in a new issue