summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/PHIElimination.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-08-17 17:43:50 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-08-17 17:43:50 +0000
commit647c5591720c197df7a9ba11515c745829e7d5a0 (patch)
tree2c7eebda39b4031bfe501f05a774d6332bb3e468 /llvm/lib/CodeGen/PHIElimination.cpp
parent5047ca0c02a3d35797413ac8a5651a6ee9537f15 (diff)
downloadbcm5719-llvm-647c5591720c197df7a9ba11515c745829e7d5a0.tar.gz
bcm5719-llvm-647c5591720c197df7a9ba11515c745829e7d5a0.zip
Move the decision logic whether it's a good idea to split a critical edge to clients. Also fixed an erroneous check. An edge is only a back edge when the from and to blocks are in the same loop.
llvm-svn: 111256
Diffstat (limited to 'llvm/lib/CodeGen/PHIElimination.cpp')
-rw-r--r--llvm/lib/CodeGen/PHIElimination.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/PHIElimination.cpp b/llvm/lib/CodeGen/PHIElimination.cpp
index 105f20b4489..11566c2d866 100644
--- a/llvm/lib/CodeGen/PHIElimination.cpp
+++ b/llvm/lib/CodeGen/PHIElimination.cpp
@@ -53,6 +53,7 @@ void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
bool llvm::PHIElimination::runOnMachineFunction(MachineFunction &MF) {
MRI = &MF.getRegInfo();
+ MLI = getAnalysisIfAvailable<MachineLoopInfo>();
bool Changed = false;
@@ -392,8 +393,14 @@ bool llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF,
// We break edges when registers are live out from the predecessor block
// (not considering PHI nodes). If the register is live in to this block
// anyway, we would gain nothing from splitting.
- if (!LV.isLiveIn(Reg, MBB) && LV.isLiveOut(Reg, *PreMBB))
- Changed |= PreMBB->SplitCriticalEdge(&MBB, this) != 0;
+ // Avoid splitting backedges of loops. It would introduce small
+ // out-of-line blocks into the loop which is very bad for code placement.
+ if (PreMBB != &MBB &&
+ !LV.isLiveIn(Reg, MBB) && LV.isLiveOut(Reg, *PreMBB)) {
+ if (!(MLI->getLoopFor(PreMBB) == MLI->getLoopFor(&MBB) &&
+ MLI->isLoopHeader(&MBB)))
+ Changed |= PreMBB->SplitCriticalEdge(&MBB, this) != 0;
+ }
}
}
return true;
OpenPOWER on IntegriCloud