summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineLICM.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-13 20:34:42 +0000
committerDan Gohman <gohman@apple.com>2010-05-13 20:34:42 +0000
commitc90f51c00bd527970c45299df108ed0e01b055a9 (patch)
treee23064c791737d29071c967ec120a0df263e03bd /llvm/lib/CodeGen/MachineLICM.cpp
parent83887a7d3a1cfb0901850c09f57be335fe245cb0 (diff)
downloadbcm5719-llvm-c90f51c00bd527970c45299df108ed0e01b055a9.tar.gz
bcm5719-llvm-c90f51c00bd527970c45299df108ed0e01b055a9.zip
Teach MachineLICM and MachineSink how to clear kill flags conservatively
when they move instructions. llvm-svn: 103737
Diffstat (limited to 'llvm/lib/CodeGen/MachineLICM.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineLICM.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index b2e757d8d65..61206173e64 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -738,8 +738,10 @@ bool MachineLICM::EliminateCSE(MachineInstr *MI,
"Instructions with different phys regs are not identical!");
if (MO.isReg() && MO.isDef() &&
- !TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
+ !TargetRegisterInfo::isPhysicalRegister(MO.getReg())) {
RegInfo->replaceRegWith(MO.getReg(), Dup->getOperand(i).getReg());
+ RegInfo->clearKillFlags(Dup->getOperand(i).getReg());
+ }
}
MI->eraseFromParent();
++NumCSEed;
@@ -784,6 +786,15 @@ void MachineLICM::Hoist(MachineInstr *MI) {
// Otherwise, splice the instruction to the preheader.
CurPreheader->splice(CurPreheader->getFirstTerminator(),MI->getParent(),MI);
+ // Clear the kill flags of any register this instruction defines,
+ // since they may need to be live throughout the entire loop
+ // rather than just live for part of it.
+ for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = MI->getOperand(i);
+ if (MO.isReg() && MO.isDef() && !MO.isDead())
+ RegInfo->clearKillFlags(MO.getReg());
+ }
+
// Add to the CSE map.
if (CI != CSEMap.end())
CI->second.push_back(MI);
OpenPOWER on IntegriCloud