diff options
author | Cong Hou <congh@google.com> | 2015-08-05 22:01:20 +0000 |
---|---|---|
committer | Cong Hou <congh@google.com> | 2015-08-05 22:01:20 +0000 |
commit | 36e7e52aa4f8d79c898d74f93711c4a0c78e253f (patch) | |
tree | 2adf8ae761c69bf9271220f2371bf51410f463f5 /llvm/lib/CodeGen/MachineBlockPlacement.cpp | |
parent | 758f3f542af978ec48745a01c998ccbbc7a7a077 (diff) | |
download | bcm5719-llvm-36e7e52aa4f8d79c898d74f93711c4a0c78e253f.tar.gz bcm5719-llvm-36e7e52aa4f8d79c898d74f93711c4a0c78e253f.zip |
Record whether the weights on out-edges from a MBB are normalized.
1. Create a utility function normalizeEdgeWeights() in MachineBranchProbabilityInfo that normalizes a list of edge weights so that the sum of then can fit in uint32_t.
2. Provide an interface in MachineBasicBlock to normalize its successors' weights.
3. Add a flag in MachineBasicBlock that tracks whether its successors' weights are normalized.
4. Provide an overload of getSumForBlock that accepts a non-const pointer to a MBB so that it can force normalizing this MBB's successors' weights.
5. Update several uses of getSumForBlock() by eliminating the once needed weight scale.
Differential Revision: http://reviews.llvm.org/D11442
llvm-svn: 244154
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index b77c803f77f..ecc093e97f5 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -361,8 +361,7 @@ MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB, // improve the MBPI interface to efficiently support query patterns such as // this. uint32_t BestWeight = 0; - uint32_t WeightScale = 0; - uint32_t SumWeight = MBPI->getSumForBlock(BB, WeightScale); + uint32_t SumWeight = MBPI->getSumForBlock(BB); DEBUG(dbgs() << "Attempting merge from: " << getBlockName(BB) << "\n"); for (MachineBasicBlock *Succ : BB->successors()) { if (BlockFilter && !BlockFilter->count(Succ)) @@ -378,7 +377,7 @@ MachineBlockPlacement::selectBestSuccessor(MachineBasicBlock *BB, } uint32_t SuccWeight = MBPI->getEdgeWeight(BB, Succ); - BranchProbability SuccProb(SuccWeight / WeightScale, SumWeight); + BranchProbability SuccProb(SuccWeight, SumWeight); // If we outline optional branches, look whether Succ is unavoidable, i.e. // dominates all terminators of the MachineFunction. If it does, other @@ -675,8 +674,7 @@ MachineBlockPlacement::findBestLoopExit(MachineFunction &F, MachineLoop &L, // FIXME: Due to the performance of the probability and weight routines in // the MBPI analysis, we use the internal weights and manually compute the // probabilities to avoid quadratic behavior. - uint32_t WeightScale = 0; - uint32_t SumWeight = MBPI->getSumForBlock(MBB, WeightScale); + uint32_t SumWeight = MBPI->getSumForBlock(MBB); for (MachineBasicBlock *Succ : MBB->successors()) { if (Succ->isLandingPad()) continue; @@ -705,7 +703,7 @@ MachineBlockPlacement::findBestLoopExit(MachineFunction &F, MachineLoop &L, BlocksExitingToOuterLoop.insert(MBB); } - BranchProbability SuccProb(SuccWeight / WeightScale, SumWeight); + BranchProbability SuccProb(SuccWeight, SumWeight); BlockFrequency ExitEdgeFreq = MBFI->getBlockFreq(MBB) * SuccProb; DEBUG(dbgs() << " exiting: " << getBlockName(MBB) << " -> " << getBlockName(Succ) << " [L:" << SuccLoopDepth << "] ("; |