llvm.org GIT mirror llvm / 670f8e5
Replace hard coded probability threshold with parameter /NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271751 91177308-0d34-0410-b5e6-96231b3b80d8 Xinliang David Li 4 years ago
2 changed file(s) with 13 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
114114 static cl::opt JumpInstCost("jump-inst-cost",
115115 cl::desc("Cost of jump instructions."),
116116 cl::init(1), cl::Hidden);
117
118 extern cl::opt StaticLikelyProb;
117119
118120 namespace {
119121 class BlockChain;
404406 MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB,
405407 BlockChain &Chain,
406408 const BlockFilterSet *BlockFilter) {
407 const BranchProbability HotProb(4, 5); // 80%
409 const BranchProbability HotProb(StaticLikelyProb, 100);
408410
409411 MachineBasicBlock *BestSucc = nullptr;
410412 auto BestProb = BranchProbability::getZero();
2323 INITIALIZE_PASS_END(MachineBranchProbabilityInfo, "machine-branch-prob",
2424 "Machine Branch Probability Analysis", false, true)
2525
26 cl::opt StaticLikelyProb(
27 "static-likely-prob",
28 cl::desc("branch probability threshold to be considered very likely"),
29 cl::init(80), cl::Hidden);
30
2631 char MachineBranchProbabilityInfo::ID = 0;
2732
28 void MachineBranchProbabilityInfo::anchor() { }
33 void MachineBranchProbabilityInfo::anchor() {}
2934
3035 BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
3136 const MachineBasicBlock *Src,
4146 std::find(Src->succ_begin(), Src->succ_end(), Dst));
4247 }
4348
44 bool
45 MachineBranchProbabilityInfo::isEdgeHot(const MachineBasicBlock *Src,
46 const MachineBasicBlock *Dst) const {
47 // Hot probability is at least 4/5 = 80%
48 static BranchProbability HotProb(4, 5);
49 bool MachineBranchProbabilityInfo::isEdgeHot(
50 const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const {
51 BranchProbability HotProb(StaticLikelyProb, 100);
4952 return getEdgeProbability(Src, Dst) > HotProb;
5053 }
5154
6265 }
6366 }
6467
65 static BranchProbability HotProb(4, 5);
68 BranchProbability HotProb(StaticLikelyProb, 100);
6669 if (getEdgeProbability(MBB, MaxSucc) >= HotProb)
6770 return MaxSucc;
6871