[PATCH] D32124: [BPI] Ignore tail while distributing the remaining probability from unreachanble
Serguei Katkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 01:03:32 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302883: [BPI] Ignore remainder while distributing the remaining probability from… (authored by skatkov).
Changed prior to commit:
https://reviews.llvm.org/D32124?vs=97406&id=98733#toc
Repository:
rL LLVM
https://reviews.llvm.org/D32124
Files:
llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll
Index: llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll
===================================================================
--- llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll
+++ llvm/trunk/test/Analysis/BranchProbabilityInfo/basic.ll
@@ -452,7 +452,7 @@
i32 3, label %case_d
i32 4, label %case_e ], !prof !8
; CHECK: edge entry -> case_a probability is 0x00000800 / 0x80000000 = 0.00%
-; CHECK: edge entry -> case_b probability is 0x07fffe01 / 0x80000000 = 6.25%
+; CHECK: edge entry -> case_b probability is 0x07fffdff / 0x80000000 = 6.25%
; CHECK: edge entry -> case_c probability is 0x67fffdff / 0x80000000 = 81.25% [HOT edge]
; CHECK: edge entry -> case_d probability is 0x07fffdff / 0x80000000 = 6.25%
; CHECK: edge entry -> case_e probability is 0x07fffdff / 0x80000000 = 6.25%
@@ -495,7 +495,7 @@
i32 4, label %case_e ], !prof !9
; CHECK: edge entry -> case_a probability is 0x00000400 / 0x80000000 = 0.00%
; CHECK: edge entry -> case_b probability is 0x00000400 / 0x80000000 = 0.00%
-; CHECK: edge entry -> case_c probability is 0x6aaaa800 / 0x80000000 = 83.33% [HOT edge]
+; CHECK: edge entry -> case_c probability is 0x6aaaa7ff / 0x80000000 = 83.33% [HOT edge]
; CHECK: edge entry -> case_d probability is 0x0aaaa7ff / 0x80000000 = 8.33%
; CHECK: edge entry -> case_e probability is 0x0aaaa7ff / 0x80000000 = 8.33%
@@ -535,7 +535,7 @@
i32 4, label %case_e ], !prof !10
; CHECK: edge entry -> case_a probability is 0x00000000 / 0x80000000 = 0.00%
; CHECK: edge entry -> case_b probability is 0x00000400 / 0x80000000 = 0.00%
-; CHECK: edge entry -> case_c probability is 0x6e08fa2e / 0x80000000 = 85.96% [HOT edge]
+; CHECK: edge entry -> case_c probability is 0x6e08fa2d / 0x80000000 = 85.96% [HOT edge]
; CHECK: edge entry -> case_d probability is 0x08fb80e9 / 0x80000000 = 7.02%
; CHECK: edge entry -> case_e probability is 0x08fb80e9 / 0x80000000 = 7.02%
Index: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
===================================================================
--- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
+++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
@@ -301,6 +301,8 @@
WeightSum += Weights[i];
}
}
+ assert(WeightSum <= UINT32_MAX &&
+ "Expected weights to scale down to 32 bits");
if (WeightSum == 0 || ReachableIdxs.size() == 0) {
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
@@ -328,21 +330,14 @@
// 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;
}
}
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
setEdgeProbability(BB, i, BP[i]);
- assert(WeightSum <= UINT32_MAX &&
- "Expected weights to scale down to 32 bits");
-
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32124.98733.patch
Type: text/x-patch
Size: 3222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170512/9b641b1f/attachment.bin>
More information about the llvm-commits
mailing list