summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-10-23 20:10:34 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-10-23 20:10:34 +0000
commit66d847c8ffff5199248fccc10cb27f80c5cf9ebe (patch)
treec85984aecdf46a13c7e758c9fd0978dac1ebc7f7 /lib/CodeGen/MachineBlockPlacement.cpp
parent4f780536953cdd3d92c21111301763ddd57ab720 (diff)
downloadllvm-66d847c8ffff5199248fccc10cb27f80c5cf9ebe.tar.gz
llvm-66d847c8ffff5199248fccc10cb27f80c5cf9ebe.tar.bz2
llvm-66d847c8ffff5199248fccc10cb27f80c5cf9ebe.tar.xz
Now that we have comparison on probabilities, add some static functions
to get important constant branch probabilities and use them for finding the best branch out of a set of possibilities. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--lib/CodeGen/MachineBlockPlacement.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/CodeGen/MachineBlockPlacement.cpp b/lib/CodeGen/MachineBlockPlacement.cpp
index 043a884f6d..32eb70e21f 100644
--- a/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/lib/CodeGen/MachineBlockPlacement.cpp
@@ -287,10 +287,8 @@ void MachineBlockPlacement::mergeSuccessor(MachineBasicBlock *BB,
return;
// Walk through the successors looking for the highest probability edge.
- // FIXME: This is an annoying way to do the comparison, but it's correct.
- // Support should be added to BranchProbability to properly compare two.
MachineBasicBlock *Successor = 0;
- BlockFrequency BestFreq;
+ BranchProbability BestProb = BranchProbability::getZero();
DEBUG(dbgs() << "Attempting merge from: " << getBlockName(BB) << "\n");
for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
SE = BB->succ_end();
@@ -298,13 +296,12 @@ void MachineBlockPlacement::mergeSuccessor(MachineBasicBlock *BB,
if (BB == *SI || (Filter && !Filter->count(*SI)))
continue;
- BlockFrequency SuccFreq(BlockFrequency::getEntryFrequency());
- SuccFreq *= MBPI->getEdgeProbability(BB, *SI);
- DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccFreq << "\n");
- if (!Successor || SuccFreq > BestFreq || (!(SuccFreq < BestFreq) &&
+ BranchProbability SuccProb = MBPI->getEdgeProbability(BB, *SI);
+ DEBUG(dbgs() << " " << getBlockName(*SI) << " -> " << SuccProb << "\n");
+ if (!Successor || SuccProb > BestProb || (!(SuccProb < BestProb) &&
BB->isLayoutSuccessor(*SI))) {
Successor = *SI;
- BestFreq = SuccFreq;
+ BestProb = SuccProb;
}
}
if (!Successor)