summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-06-15 03:03:30 +0000
committerXinliang David Li <davidxl@google.com>2016-06-15 03:03:30 +0000
commite34ed833e50c279e2f25ce944404d3091ade5190 (patch)
treefefa41d621972f0515d7356ad548c3ca36ea61de /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parent89049702ce6c979355dbcb8945364289599af9e2 (diff)
downloadbcm5719-llvm-e34ed833e50c279e2f25ce944404d3091ade5190.tar.gz
bcm5719-llvm-e34ed833e50c279e2f25ce944404d3091ade5190.zip
[MBP] add comments and bug fix
Document the new parameter and threshod computation model. Also fix a bug when the threshold parameter is set to be different from the default. llvm-svn: 272749
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 7379a3099b1..332755d0ff4 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -530,9 +530,19 @@ static BranchProbability getLayoutSuccessorProbThreshold(
if (BB->succ_size() == 2) {
const MachineBasicBlock *Succ1 = *BB->succ_begin();
const MachineBasicBlock *Succ2 = *(BB->succ_begin() + 1);
- if (Succ1->isSuccessor(Succ2) || Succ2->isSuccessor(Succ1))
- return BranchProbability(
- 200 - 2 * ProfileLikelyProb, 200 - ProfileLikelyProb);
+ if (Succ1->isSuccessor(Succ2) || Succ2->isSuccessor(Succ1)) {
+ /* See case 1 below for the cost analysis. For BB->Succ to
+ * be taken with smaller cost, the following needs to hold:
+ * Prob(BB->Succ) > 2* Prob(BB->Pred)
+ * So the threshold T
+ * T = 2 * (1-Prob(BB->Pred). Since T + Prob(BB->Pred) == 1,
+ * We have T + T/2 = 1, i.e. T = 2/3. Also adding user specified
+ * branch bias, we have
+ * T = (2/3)*(ProfileLikelyProb/50)
+ * = (2*ProfileLikelyProb)/150)
+ */
+ return BranchProbability(2 * ProfileLikelyProb, 150);
+ }
}
return BranchProbability(ProfileLikelyProb, 100);
}
OpenPOWER on IntegriCloud