diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-10-23 20:10:34 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-10-23 20:10:34 +0000 |
commit | fd7475e90678e7a0293e07e87f82115625d69a37 (patch) | |
tree | cb55d83d05915479463b893fed898d46d174e6ad /llvm/lib/CodeGen/MachineBlockPlacement.cpp | |
parent | 446210b61635bb07c8321586ed6db92b88d0cfee (diff) | |
download | bcm5719-llvm-fd7475e90678e7a0293e07e87f82115625d69a37.tar.gz bcm5719-llvm-fd7475e90678e7a0293e07e87f82115625d69a37.zip |
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.
llvm-svn: 142762
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 043a884f6d4..32eb70e21ff 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/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) |