Previously in isProfitableToIfCvt() in ARMBaseInstrInfo.cpp, the multiplication between an integer and a branch probability is done manually in an unsafe way that may lead to overflow. This patch corrects those cases by using BranchProbability's member function scale() to avoid overflow (which stores the intermediate result in int64).
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
This looks sane to me. Do you have a code where it fails? Would it be possible to turn into a test?
Comment Actions
When the probability is represented with a very large numerator, we will get overflow here (this happened to me when I changed the representation of the BranchProbability by using a very large fixed denominator). BranchProbability provides scale() interface just for this case, so using it should be the right way to scale an integer. Is a test necessary for this fix?
Comment Actions
If the problem was found with a test case, then yes. But if it was just you fiddling with internal constants, I think the patch is obvious and should be ok without a test.