[PATCH] D32124: [BPI] Follow up rL300440. NFC
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 16 23:47:43 PDT 2017
skatkov created this revision.
This is a follow up patch for https://reviews.llvm.org/rL300440
to address a comment.
https://reviews.llvm.org/D32124
Files:
include/llvm/Support/BranchProbability.h
lib/Analysis/BranchProbabilityInfo.cpp
Index: lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- lib/Analysis/BranchProbabilityInfo.cpp
+++ lib/Analysis/BranchProbabilityInfo.cpp
@@ -328,12 +328,10 @@
// the difference between reachable blocks.
if (ToDistribute > BranchProbability::getZero()) {
BranchProbability PerEdge = ToDistribute / ReachableIdxs.size();
- for (auto i : ReachableIdxs) {
+ for (auto i : ReachableIdxs)
BP[i] += PerEdge;
- ToDistribute -= PerEdge;
- }
// Tail goes to the first reachable edge.
- BP[ReachableIdxs[0]] += ToDistribute;
+ BP[ReachableIdxs[0]] += ToDistribute - (PerEdge * ReachableIdxs.size());
}
}
Index: include/llvm/Support/BranchProbability.h
===================================================================
--- include/llvm/Support/BranchProbability.h
+++ include/llvm/Support/BranchProbability.h
@@ -112,6 +112,13 @@
return *this;
}
+ BranchProbability &operator*=(uint32_t RHS) {
+ assert(N != UnknownN &&
+ "Unknown probability cannot participate in arithmetics.");
+ N = (uint64_t(N) * RHS > D) ? D : N * RHS;
+ return *this;
+ }
+
BranchProbability &operator/=(uint32_t RHS) {
assert(N != UnknownN &&
"Unknown probability cannot participate in arithmetics.");
@@ -135,6 +142,11 @@
return Prob *= RHS;
}
+ BranchProbability operator*(uint32_t RHS) const {
+ BranchProbability Prob(*this);
+ return Prob *= RHS;
+ }
+
BranchProbability operator/(uint32_t RHS) const {
BranchProbability Prob(*this);
return Prob /= RHS;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32124.95423.patch
Type: text/x-patch
Size: 1644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170417/8bdac741/attachment.bin>
More information about the llvm-commits
mailing list