[PATCH] D15519: Replace weights by probabilities in BPI.
Cong Hou via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 18 14:23:03 PST 2015
congh added inline comments.
================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:143
@@ -149,9 +142,3 @@
- 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());
----------------
congh wrote:
> davidxl wrote:
> > Can we unify the code a little more:
> >
> > BranchProbability UnreachableProb =
> > ( ReachableEdges.empty() ?
> > BranchProbability(1, UnreachableEdges.size()) :
> > BranchProbability(UR_TAKEN_WEIGHT, (....) * UnreachableEdges.size()));
> > BranchProbability ReachableProb = (UR_NOTAKEN_WEIGHT, ReachableEdges.size() * ...);
> >
> > for (...: UnreachableEdges)
> > set...
> > for (...)
> > set ...
> >
> OK. We can set UnreachableProb to 100% when ReachableEdges is empty.
I later found that I have to take care of the non-zero divider case here. To make the code more clear, I think the early exit solution might be better.
http://reviews.llvm.org/D15519
More information about the llvm-commits
mailing list