diff options
author | Evan Cheng <evan.cheng@apple.com> | 2010-08-17 01:20:36 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2010-08-17 01:20:36 +0000 |
commit | f259efde4730f1c8ba33f6a16f9b93c1e01165f5 (patch) | |
tree | edb19bf7ab8844339775d7539a1fcd703016d833 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | d84dbb5cafc429076b6925117783ce37358d3dbd (diff) | |
download | bcm5719-llvm-f259efde4730f1c8ba33f6a16f9b93c1e01165f5.tar.gz bcm5719-llvm-f259efde4730f1c8ba33f6a16f9b93c1e01165f5.zip |
PHI elimination should not break back edge. It can cause some significant code placement issues. rdar://8263994
good:
LBB0_2:
mov r2, r0
. . .
mov r1, r2
bne LBB0_2
bad:
LBB0_2:
mov r2, r0
. . .
@ BB#3:
mov r1, r2
b LBB0_2
llvm-svn: 111221
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index a27ee479433..895653d18de 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -439,6 +439,14 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) { if (TII->AnalyzeBranch(*this, TBB, FBB, Cond)) return NULL; + // Avoid splitting backedges of loops. It would introduce small out-of-line + // blocks into the loop which is very bad for code placement. + if (this == Succ) + return NULL; + MachineLoopInfo *MLI = P->getAnalysisIfAvailable<MachineLoopInfo>(); + if (MLI->isLoopHeader(Succ)) + return NULL; + MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(); MF->insert(llvm::next(MachineFunction::iterator(this)), NMBB); DEBUG(dbgs() << "PHIElimination splitting critical edge:" @@ -471,8 +479,7 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) { P->getAnalysisIfAvailable<MachineDominatorTree>()) MDT->addNewBlock(NMBB, this); - if (MachineLoopInfo *MLI = - P->getAnalysisIfAvailable<MachineLoopInfo>()) + if (MLI) if (MachineLoop *TIL = MLI->getLoopFor(this)) { // If one or the other blocks were not in a loop, the new block is not // either, and thus LI doesn't need to be updated. |