mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[BranchProbabilityInfo] Simplify getEdgeProbability (NFC)
The patch simplifies BranchProbabilityInfo::getEdgeProbability by handling two cases separately, depending on whether we have edge probabilities. - If we have edge probabilities, then add up probabilities for successors being equal to Dst. - Otherwise, return the number of ocurrences divided by the total number of successors. Differential Revision: https://reviews.llvm.org/D90980
This commit is contained in:
parent
8b06f86d2f
commit
f462bf9b0e
@ -1114,19 +1114,15 @@ BranchProbabilityInfo::getEdgeProbability(const BasicBlock *Src,
|
|||||||
BranchProbability
|
BranchProbability
|
||||||
BranchProbabilityInfo::getEdgeProbability(const BasicBlock *Src,
|
BranchProbabilityInfo::getEdgeProbability(const BasicBlock *Src,
|
||||||
const BasicBlock *Dst) const {
|
const BasicBlock *Dst) const {
|
||||||
|
if (!Probs.count(std::make_pair(Src, 0)))
|
||||||
|
return BranchProbability(llvm::count(successors(Src), Dst), succ_size(Src));
|
||||||
|
|
||||||
auto Prob = BranchProbability::getZero();
|
auto Prob = BranchProbability::getZero();
|
||||||
bool FoundProb = false;
|
|
||||||
uint32_t EdgeCount = 0;
|
|
||||||
for (const_succ_iterator I = succ_begin(Src), E = succ_end(Src); I != E; ++I)
|
for (const_succ_iterator I = succ_begin(Src), E = succ_end(Src); I != E; ++I)
|
||||||
if (*I == Dst) {
|
if (*I == Dst)
|
||||||
++EdgeCount;
|
Prob += Probs.find(std::make_pair(Src, I.getSuccessorIndex()))->second;
|
||||||
auto MapI = Probs.find(std::make_pair(Src, I.getSuccessorIndex()));
|
|
||||||
if (MapI != Probs.end()) {
|
return Prob;
|
||||||
FoundProb = true;
|
|
||||||
Prob += MapI->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FoundProb ? Prob : BranchProbability(EdgeCount, succ_size(Src));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the edge probability for all edges at once.
|
/// Set the edge probability for all edges at once.
|
||||||
|
Loading…
Reference in New Issue
Block a user