diff options
author | Cong Hou <congh@google.com> | 2015-12-22 18:56:14 +0000 |
---|---|---|
committer | Cong Hou <congh@google.com> | 2015-12-22 18:56:14 +0000 |
commit | e93b8e1539857d770cdd5a815b4bc3f3eb474e51 (patch) | |
tree | d34ed3f2714f3d216a58a42368b215c08f36631a /llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | |
parent | 4e4f60ded087ac264a05dd1738d20cde60932cb2 (diff) | |
download | bcm5719-llvm-e93b8e1539857d770cdd5a815b4bc3f3eb474e51.tar.gz bcm5719-llvm-e93b8e1539857d770cdd5a815b4bc3f3eb474e51.zip |
[BPI] Replace weights by probabilities in BPI.
This patch removes all weight-related interfaces from BPI and replace
them by probability versions. With this patch, we won't use edge weight
anymore in either IR or MC passes. Edge probabilitiy is a better
representation in terms of CFG update and validation.
Differential revision: http://reviews.llvm.org/D15519
llvm-svn: 256263
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index d57a070bcd5..a2d588c8c26 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -414,8 +414,8 @@ static unsigned getBranchHint(unsigned PCC, FunctionLoweringInfo *FuncInfo, const BasicBlock *TBB = BBTerm->getSuccessor(0); const BasicBlock *FBB = BBTerm->getSuccessor(1); - uint32_t TWeight = FuncInfo->BPI->getEdgeWeight(BB, TBB); - uint32_t FWeight = FuncInfo->BPI->getEdgeWeight(BB, FBB); + auto TProb = FuncInfo->BPI->getEdgeProbability(BB, TBB); + auto FProb = FuncInfo->BPI->getEdgeProbability(BB, FBB); // We only want to handle cases which are easy to predict at static time, e.g. // C++ throw statement, that is very likely not taken, or calling never @@ -432,24 +432,22 @@ static unsigned getBranchHint(unsigned PCC, FunctionLoweringInfo *FuncInfo, // 5. PH/ZH/FPH 20:12 const uint32_t Threshold = 10000; - // Minimal weight should be at least 1 - if (std::max(TWeight, FWeight) / - std::max(1u, std::min(TWeight, FWeight)) < Threshold) + if (std::max(TProb, FProb) / Threshold < std::min(TProb, FProb)) return PPC::BR_NO_HINT; DEBUG(dbgs() << "Use branch hint for '" << FuncInfo->Fn->getName() << "::" << BB->getName() << "'\n" - << " -> " << TBB->getName() << ": " << TWeight << "\n" - << " -> " << FBB->getName() << ": " << FWeight << "\n"); + << " -> " << TBB->getName() << ": " << TProb << "\n" + << " -> " << FBB->getName() << ": " << FProb << "\n"); const BasicBlockSDNode *BBDN = cast<BasicBlockSDNode>(DestMBB); - // If Dest BasicBlock is False-BasicBlock (FBB), swap branch weight, - // because we want 'TWeight' stands for 'branch weight' to Dest BasicBlock + // If Dest BasicBlock is False-BasicBlock (FBB), swap branch probabilities, + // because we want 'TProb' stands for 'branch probability' to Dest BasicBlock if (BBDN->getBasicBlock()->getBasicBlock() != TBB) - std::swap(TWeight, FWeight); + std::swap(TProb, FProb); - return (TWeight > FWeight) ? PPC::BR_TAKEN_HINT : PPC::BR_NONTAKEN_HINT; + return (TProb > FProb) ? PPC::BR_TAKEN_HINT : PPC::BR_NONTAKEN_HINT; } // isOpcWithIntImmediate - This method tests to see if the node is a specific |