From 9eb77bf6151ea278c7afbb3e370781f34a8ba5cc Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 19 Aug 2011 00:30:17 +0000 Subject: Don't treat a partial operand as a read. Normally, a partial register def is treated as reading the super-register unless it also defines the full register like this: %vreg110:sub_32bit = COPY %vreg77:sub_32bit, %vreg110 This patch also uses the flag on partial defs to recognize non-reading operands: %vreg110:sub_32bit = COPY %vreg77:sub_32bit This fixes a subtle bug in RegisterCoalescer where LIS->shrinkToUses would treat a coalesced copy as still reading the register, extending the live range artificially. My test case only works when I disable DCE so a dead copy is left for RegisterCoalescer, so I am not including it. llvm-svn: 138018 --- llvm/lib/CodeGen/MachineInstr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm') diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 97fe6f48935..11ecc84ded5 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -901,7 +901,8 @@ MachineInstr::readsWritesVirtualRegister(unsigned Reg, Ops->push_back(i); if (MO.isUse()) Use |= !MO.isUndef(); - else if (MO.getSubReg()) + else if (MO.getSubReg() && !MO.isUndef()) + // A partial doesn't count as reading the register. PartDef = true; else FullDef = true; -- cgit v1.2.3