[PATCH] D12742: [ARM] Scaling up values in ARMBaseInstrInfo::isProfitableToIfCvt() before they are scaled by a probability to avoid precision issue.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 16:35:32 PDT 2015

congh created this revision.
congh added reviewers: rengolin, t.p.northover, davidxl.
congh added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

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.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12742.34384.patch
Type: text/x-patch
Size: 5008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150909/6509518c/attachment.bin>

More information about the llvm-commits mailing list