summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-08-19 18:33:29 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-08-19 18:33:29 +0000
commite5e7946018844978d0ac09fdb35998a53b43ad34 (patch)
tree78ba9b04c257e70c674d2f160f5cc2057e250dea /lib/CodeGen/MachineSink.cpp
parent6715be20e23ac19efd20e16d43fdd1f608e3e415 (diff)
downloadllvm-e5e7946018844978d0ac09fdb35998a53b43ad34.tar.gz
llvm-e5e7946018844978d0ac09fdb35998a53b43ad34.tar.bz2
llvm-e5e7946018844978d0ac09fdb35998a53b43ad34.tar.xz
It's possible to sink a def if its local uses are PHI's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineSink.cpp')
-rw-r--r--lib/CodeGen/MachineSink.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/CodeGen/MachineSink.cpp b/lib/CodeGen/MachineSink.cpp
index d79b3751ec..2f8e9ffdf9 100644
--- a/lib/CodeGen/MachineSink.cpp
+++ b/lib/CodeGen/MachineSink.cpp
@@ -103,15 +103,14 @@ bool MachineSinking::AllUsesDominatedByBlock(unsigned Reg,
// Determine the block of the use.
MachineInstr *UseInst = &*I;
MachineBasicBlock *UseBlock = UseInst->getParent();
- if (UseBlock == DefMBB) {
- LocalUse = true;
- return false;
- }
if (UseInst->isPHI()) {
// PHI nodes use the operand in the predecessor block, not the block with
// the PHI.
UseBlock = UseInst->getOperand(I.getOperandNo()+1).getMBB();
+ } else if (UseBlock == DefMBB) {
+ LocalUse = true;
+ return false;
}
// Check that it dominates.
@@ -270,7 +269,6 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI, bool &SawStore) {
// decide.
MachineBasicBlock *SuccToSinkTo = 0;
- bool LocalUse = false;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
const MachineOperand &MO = MI->getOperand(i);
if (!MO.isReg()) continue; // Ignore non-register operands.
@@ -328,6 +326,7 @@ bool MachineSinking::SinkInstruction(MachineInstr *MI, bool &SawStore) {
if (SuccToSinkTo) {
// If a previous operand picked a block to sink to, then this operand
// must be sinkable to the same block.
+ bool LocalUse = false;
if (!AllUsesDominatedByBlock(Reg, SuccToSinkTo, ParentBlock, LocalUse))
return false;
@@ -338,6 +337,7 @@ 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) {
+ bool LocalUse = false;
if (AllUsesDominatedByBlock(Reg, *SI, ParentBlock, LocalUse)) {
SuccToSinkTo = *SI;
break;