In ARMBaseInstrInfo::isProfitableToIfCvt(), there is a simple cost model in which the number of cycles is scaled by a probability to estimate the cost. However, when the number of cycles is small (which is usually the case), there is a precision issue after the computation. For example, for the following code from ARMBaseInstrInfo::isProfitableToIfCvt():
unsigned TUnpredCost = Probability.scale(TCycles); unsigned FUnpredCost = Probability.getCompl().scale(FCycles); unsigned UnpredCost = TUnpredCost + FUnpredCost;
Assume Probability is 0.5 and both TCycles and FCycles are 1, the resulted UnpredCost is 0 while 1 should be a more reasonable result. To avoid this issue, this patch scales both TCycles and FCycles up by 1024 (chosen to make the multiplication a litter faster) before they are scaled by the probability. Other variables also need to be scaled up for the final comparison.
Several test cases are adjusted due to this change.