forked from OSchip/llvm-project
[CodeGen] Fix the branch probability assertion in r318202
Due to integer precision, we might have numerator greater than denominator in the branch probability scaling. Add a check to prevent this from happening. llvm-svn: 318353
This commit is contained in:
parent
725584e26d
commit
e4572c6b73
|
@ -9847,8 +9847,10 @@ static BranchProbability scaleCaseProbality(BranchProbability CaseProb,
|
|||
if (PeeledCaseProb == BranchProbability::getOne())
|
||||
return BranchProbability::getZero();
|
||||
BranchProbability SwitchProb = PeeledCaseProb.getCompl();
|
||||
return BranchProbability(CaseProb.getNumerator(),
|
||||
SwitchProb.scale(CaseProb.getDenominator()));
|
||||
|
||||
uint32_t Numerator = CaseProb.getNumerator();
|
||||
uint32_t Denominator = SwitchProb.scale(CaseProb.getDenominator());
|
||||
return BranchProbability(Numerator, std::max(Numerator, Denominator));
|
||||
}
|
||||
|
||||
// Try to peel the top probability case if it exceeds the threshold.
|
||||
|
|
Loading…
Reference in New Issue