aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/TwoAddressInstructionPass.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2011-11-16 03:47:42 +0000
committerEvan Cheng <evan.cheng@apple.com>2011-11-16 03:47:42 +0000
commit9bad88a9def4abaa87e7e5e7178bd680354043f8 (patch)
tree0b95d0d3b336a335f7e0f26339900cdf0945a542 /lib/CodeGen/TwoAddressInstructionPass.cpp
parent2bee6a8bb74724263eadd550ee76417d6e6465a9 (diff)
If the 2addr instruction has other kills, don't move it below any other uses since we don't want to extend other live ranges.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index 3e9a0e44e9..7a0fcb5651 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -933,6 +933,7 @@ TwoAddressInstructionPass::RescheduleMIBelowKill(MachineBasicBlock *MBB,
return false;
SmallSet<unsigned, 2> Uses;
+ SmallSet<unsigned, 2> Kills;
SmallSet<unsigned, 2> Defs;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
const MachineOperand &MO = MI->getOperand(i);
@@ -943,8 +944,11 @@ TwoAddressInstructionPass::RescheduleMIBelowKill(MachineBasicBlock *MBB,
continue;
if (MO.isDef())
Defs.insert(MOReg);
- else
+ else {
Uses.insert(MOReg);
+ if (MO.isKill() && MOReg != Reg)
+ Kills.insert(MOReg);
+ }
}
// Move the copies connected to MI down as well.
@@ -991,7 +995,8 @@ TwoAddressInstructionPass::RescheduleMIBelowKill(MachineBasicBlock *MBB,
} else {
if (Defs.count(MOReg))
return false;
- if (MOReg != Reg && MO.isKill() && Uses.count(MOReg))
+ if (MOReg != Reg &&
+ ((MO.isKill() && Uses.count(MOReg)) || Kills.count(MOReg)))
// Don't want to extend other live ranges and update kills.
return false;
}