aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-12-08 21:33:23 +0000
committerDevang Patel <dpatel@apple.com>2011-12-08 21:33:23 +0000
commit1a3c1697f9e8c9ada70808aece20fedf46fde6d9 (patch)
treea1ae716d3cf6a63943650a06e1c0289872583f82 /llvm/lib/CodeGen/MachineSink.cpp
parentf10ee84956d867e420c0f2e3c8b0d924e7b13746 (diff)
downloadllvm-1a3c1697f9e8c9ada70808aece20fedf46fde6d9.zip
llvm-1a3c1697f9e8c9ada70808aece20fedf46fde6d9.tar.gz
llvm-1a3c1697f9e8c9ada70808aece20fedf46fde6d9.tar.bz2
Filter "sink to" candidate blocks sooner. This avoids unnecessary computation to determine whether the block dominates all uses or not.
llvm-svn: 146184
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 8a34237..0d14b63 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -499,10 +499,21 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI, bool &SawStore) {
// we should sink to.
for (MachineBasicBlock::succ_iterator SI = ParentBlock->succ_begin(),
E = ParentBlock->succ_end(); SI != E; ++SI) {
+ MachineBasicBlock *SuccBlock = *SI;
+ // It is not possible to sink an instruction into its own block. This can
+ // happen with loops.
+ if (ParentBlock == SuccBlock)
+ continue;
+
+ // It's not safe to sink instructions to EH landing pad. Control flow into
+ // landing pad is implicitly defined.
+ if (SuccBlock->isLandingPad())
+ continue;
+
bool LocalUse = false;
- if (AllUsesDominatedByBlock(Reg, *SI, ParentBlock,
+ if (AllUsesDominatedByBlock(Reg, SuccBlock, ParentBlock,
BreakPHIEdge, LocalUse)) {
- SuccToSinkTo = *SI;
+ SuccToSinkTo = SuccBlock;
break;
}
if (LocalUse)
@@ -520,15 +531,6 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI, bool &SawStore) {
if (SuccToSinkTo == 0)
return false;
- // It's not safe to sink instructions to EH landing pad. Control flow into
- // landing pad is implicitly defined.
- if (SuccToSinkTo->isLandingPad())
- return false;
-
- // It is not possible to sink an instruction into its own block. This can
- // happen with loops.
- if (MI->getParent() == SuccToSinkTo)
- return false;
// If the instruction to move defines a dead physical register which is live
// when leaving the basic block, don't move it because it could turn into a