[PATCH] D62430: [PPC] Correctly adjust branch probability in PPCReduceCRLogicals

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 08:20:20 PDT 2019


Carrot marked an inline comment as done.
Carrot added inline comments.


================
Comment at: include/llvm/Support/BranchProbability.h:161
+  BranchProbability sqrt() const {
+    double P = (double)N / (double)D;
+    P = std::sqrt(P);
----------------
hfinkel wrote:
> This would be the first use of floating-point here, right? Can we do this any other way?
Suppose the original branch probability to Target is P0, after splitting MBB, there are two branches to Target, the probability to it is P1 and P2. If the edge frequency to Target is same, then

    F * P1 = F * P0 / 2                    ==>  P1 = P0 / 2
    F * (1 - P1) * P2 = F * P1          ==>  P2 = P1 / (1 - P1)

With this distribution we can avoid square root.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62430/new/

https://reviews.llvm.org/D62430





More information about the llvm-commits mailing list