[PATCH] D12603: Use fixed-point representation for BranchProbability

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 13:51:13 PDT 2015


congh added inline comments.

================
Comment at: lib/Support/BranchProbability.cpp:98
@@ -59,3 +97,3 @@
   Rem = ((Rem % D) << 32) | Lower32;
-  uint64_t LowerQ = Rem / D;
+  uint64_t LowerQ = (Rem + D / 2) / D;
   uint64_t Q = (UpperQ << 32) + LowerQ;
----------------
davidxl wrote:
> Should D/2 be added to ProductLow above (and check overflow and carry bit)?
> 
> Besides, independent on what scale factor to use for BP,  I think this change should not be included in this patch. It changes the rounding behavior of the scale() method (instead of truncating) which is irrelevant to the main purpose of the patch. This should be done as a follow up patch if it is desirable.
It is the division by D that may cause precision loss and I think this is the proper place to add D/2.

It is OK to separate this change to another patch (if it is necessary). This will cause many test failures and I will fix them as long as this patch is approved.


http://reviews.llvm.org/D12603





More information about the llvm-commits mailing list