[PATCH] D15519: Replace weights by probabilities in BPI.
David Li via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 21 16:24:25 PST 2015
davidxl added inline comments.
================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:143-146
@@ -149,10 +142,6 @@
- uint32_t UnreachableWeight =
- std::max(UR_TAKEN_WEIGHT / (unsigned)UnreachableEdges.size(), MIN_WEIGHT);
- for (SmallVectorImpl<unsigned>::iterator I = UnreachableEdges.begin(),
- E = UnreachableEdges.end();
- I != E; ++I)
- setEdgeWeight(BB, *I, UnreachableWeight);
-
- if (ReachableEdges.empty())
+ if (ReachableEdges.empty()) {
+ BranchProbability Prob(1, UnreachableEdges.size());
+ for (unsigned SuccIdx : UnreachableEdges)
+ setEdgeProbability(BB, SuccIdx, Prob);
return true;
----------------
Instead of using division later, why not use the multiplication suggestion in my previous comment? The weight is small enough that there is no risk of overflowing.
================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:347
@@ +346,3 @@
+ SmallVector<BranchProbability, 4> Probs(3, BranchProbability::getZero());
+ if (!BackEdges.empty())
+ Probs[0] = BranchProbability(LBH_TAKEN_WEIGHT,
----------------
Does it matter here? As you can see it is guarded later -- so there is no functional change here. Removing the guard makes code look cleaner
http://reviews.llvm.org/D15519
More information about the llvm-commits
mailing list