[PATCH] D15519: Replace weights by probabilities in BPI.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 22 10:38:52 PST 2015


congh added inline comments.

================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:349
@@ +348,3 @@
+  SmallVector<BranchProbability, 4> Probs(3, BranchProbability::getZero());
+  if (!BackEdges.empty())
+    Probs[0] = BranchProbability(LBH_TAKEN_WEIGHT,
----------------
davidxl wrote:
> Ok, I now see the normalization is done before prob assignment. However I think we can get rid of the normalization completely by computing the right denorm value in the first place. Say the number of back edges is B, number of In edges is I, and number of exiting edges are E, the denorm is
> 
> D =  (B? TAKEN_WEIGHT: 0) + (I ? TAKEN_WEIGHT : 0) + (E ? NON_TAKEN_WEIGHT : 0)
> 
> So a backedge prob (if exists) is:
> 
> Prob(backedge) = TAKEN_WEIGHT/(D*B)
> 
OK. I have updated the patch accordingly.


http://reviews.llvm.org/D15519





More information about the llvm-commits mailing list