forked from OSchip/llvm-project
Replace hard coded probability threshold with parameter /NFC
llvm-svn: 271751
This commit is contained in:
parent
7bae9adb08
commit
ff2873742e
|
@ -116,6 +116,8 @@ static cl::opt<unsigned> JumpInstCost("jump-inst-cost",
|
||||||
cl::desc("Cost of jump instructions."),
|
cl::desc("Cost of jump instructions."),
|
||||||
cl::init(1), cl::Hidden);
|
cl::init(1), cl::Hidden);
|
||||||
|
|
||||||
|
extern cl::opt<unsigned> StaticLikelyProb;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class BlockChain;
|
class BlockChain;
|
||||||
/// \brief Type for our function-wide basic block -> block chain mapping.
|
/// \brief Type for our function-wide basic block -> block chain mapping.
|
||||||
|
@ -405,7 +407,7 @@ MachineBasicBlock *
|
||||||
MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB,
|
MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB,
|
||||||
BlockChain &Chain,
|
BlockChain &Chain,
|
||||||
const BlockFilterSet *BlockFilter) {
|
const BlockFilterSet *BlockFilter) {
|
||||||
const BranchProbability HotProb(4, 5); // 80%
|
const BranchProbability HotProb(StaticLikelyProb, 100);
|
||||||
|
|
||||||
MachineBasicBlock *BestSucc = nullptr;
|
MachineBasicBlock *BestSucc = nullptr;
|
||||||
auto BestProb = BranchProbability::getZero();
|
auto BestProb = BranchProbability::getZero();
|
||||||
|
|
|
@ -24,9 +24,14 @@ INITIALIZE_PASS_BEGIN(MachineBranchProbabilityInfo, "machine-branch-prob",
|
||||||
INITIALIZE_PASS_END(MachineBranchProbabilityInfo, "machine-branch-prob",
|
INITIALIZE_PASS_END(MachineBranchProbabilityInfo, "machine-branch-prob",
|
||||||
"Machine Branch Probability Analysis", false, true)
|
"Machine Branch Probability Analysis", false, true)
|
||||||
|
|
||||||
|
cl::opt<unsigned> StaticLikelyProb(
|
||||||
|
"static-likely-prob",
|
||||||
|
cl::desc("branch probability threshold to be considered very likely"),
|
||||||
|
cl::init(80), cl::Hidden);
|
||||||
|
|
||||||
char MachineBranchProbabilityInfo::ID = 0;
|
char MachineBranchProbabilityInfo::ID = 0;
|
||||||
|
|
||||||
void MachineBranchProbabilityInfo::anchor() { }
|
void MachineBranchProbabilityInfo::anchor() {}
|
||||||
|
|
||||||
BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
|
BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
|
||||||
const MachineBasicBlock *Src,
|
const MachineBasicBlock *Src,
|
||||||
|
@ -42,11 +47,9 @@ BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
|
||||||
std::find(Src->succ_begin(), Src->succ_end(), Dst));
|
std::find(Src->succ_begin(), Src->succ_end(), Dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool MachineBranchProbabilityInfo::isEdgeHot(
|
||||||
MachineBranchProbabilityInfo::isEdgeHot(const MachineBasicBlock *Src,
|
const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const {
|
||||||
const MachineBasicBlock *Dst) const {
|
BranchProbability HotProb(StaticLikelyProb, 100);
|
||||||
// Hot probability is at least 4/5 = 80%
|
|
||||||
static BranchProbability HotProb(4, 5);
|
|
||||||
return getEdgeProbability(Src, Dst) > HotProb;
|
return getEdgeProbability(Src, Dst) > HotProb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +66,7 @@ MachineBranchProbabilityInfo::getHotSucc(MachineBasicBlock *MBB) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BranchProbability HotProb(4, 5);
|
BranchProbability HotProb(StaticLikelyProb, 100);
|
||||||
if (getEdgeProbability(MBB, MaxSucc) >= HotProb)
|
if (getEdgeProbability(MBB, MaxSucc) >= HotProb)
|
||||||
return MaxSucc;
|
return MaxSucc;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue