[PATCH] D12295: Use BranchProbability::scale() to scale an integer with a probability in ARMBaseInstrInfo.cpp,

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 16:19:02 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL246106: [ARM] Use BranchProbability::scale() to scale an integer with a probability… (authored by conghou).

Changed prior to commit:
  http://reviews.llvm.org/D12295?vs=33002&id=33268#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12295

Files:
  llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp

Index: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -1670,8 +1670,7 @@
   }
 
   // Attempt to estimate the relative costs of predication versus branching.
-  unsigned UnpredCost = Probability.getNumerator() * NumCycles;
-  UnpredCost /= Probability.getDenominator();
+  unsigned UnpredCost = Probability.scale(NumCycles);
   UnpredCost += 1; // The branch itself
   UnpredCost += Subtarget.getMispredictionPenalty() / 10;
 
@@ -1688,13 +1687,8 @@
     return false;
 
   // Attempt to estimate the relative costs of predication versus branching.
-  unsigned TUnpredCost = Probability.getNumerator() * TCycles;
-  TUnpredCost /= Probability.getDenominator();
-
-  uint32_t Comp = Probability.getDenominator() - Probability.getNumerator();
-  unsigned FUnpredCost = Comp * FCycles;
-  FUnpredCost /= Probability.getDenominator();
-
+  unsigned TUnpredCost = Probability.scale(TCycles);
+  unsigned FUnpredCost = Probability.getCompl().scale(FCycles);
   unsigned UnpredCost = TUnpredCost + FUnpredCost;
   UnpredCost += 1; // The branch itself
   UnpredCost += Subtarget.getMispredictionPenalty() / 10;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12295.33268.patch
Type: text/x-patch
Size: 1277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150826/154c2038/attachment.bin>


More information about the llvm-commits mailing list