diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-08-17 17:43:50 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-08-17 17:43:50 +0000 |
commit | e008384508342a2dec110eafaa87d93614976990 (patch) | |
tree | 9b55d84fea5b3777135ce41c11bc676ac50e6a43 /lib/CodeGen/PHIElimination.cpp | |
parent | fc8042a1225790b3a6de434546623babea08496f (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111256 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/PHIElimination.cpp')
-rw-r--r-- | lib/CodeGen/PHIElimination.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index 105f20b448..11566c2d86 100644 --- a/lib/CodeGen/PHIElimination.cpp +++ b/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; |