summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-01 17:18:50 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-01 17:18:50 +0000
commit6357fa2f0684781d711d92826f39aeadfccec7f6 (patch)
tree91ca3ae633de1a412a792682178034d1d9c476c5 /llvm/lib
parent4a69c2e6c59ae69d2409964e40214d617c106db2 (diff)
downloadbcm5719-llvm-6357fa2f0684781d711d92826f39aeadfccec7f6.tar.gz
bcm5719-llvm-6357fa2f0684781d711d92826f39aeadfccec7f6.zip
Prevent remat of partial register redefinitions.
An instruction that redefines only part of a larger register can never be rematerialized since the virtual register value depends on the old value in other parts of the register. This was fixed for the inline spiller in r138794. This patch fixes the problem for all register allocators, and includes a small test case. <rdar://problem/10032939> llvm-svn: 138944
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TargetInstrInfoImpl.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp b/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp
index ea0cfe2b940..1cd42ca2ae0 100644
--- a/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfoImpl.cpp
@@ -362,6 +362,15 @@ isReallyTriviallyReMaterializableGeneric(const MachineInstr *MI,
const TargetInstrInfo &TII = *TM.getInstrInfo();
const TargetRegisterInfo &TRI = *TM.getRegisterInfo();
+ // A sub-register definition can only be rematerialized if the instruction
+ // doesn't read the other parts of the register. Otherwise it is really a
+ // read-modify-write operation on the full virtual register which cannot be
+ // moved safely.
+ unsigned Reg = MI->getOperand(0).getReg();
+ if (TargetRegisterInfo::isVirtualRegister(Reg) &&
+ MI->getOperand(0).getSubReg() && MI->readsVirtualRegister(Reg))
+ return false;
+
// A load from a fixed stack slot can be rematerialized. This may be
// redundant with subsequent checks, but it's target-independent,
// simple, and a common case.
OpenPOWER on IntegriCloud