[llvm-commits] [llvm] r56085 - in /llvm/trunk: lib/CodeGen/VirtRegMap.cpp test/CodeGen/X86/2008-09-10-SpillerBug2.ll

Evan Cheng evan.cheng at apple.com
Wed Sep 10 18:02:12 PDT 2008


Author: evancheng
Date: Wed Sep 10 20:02:12 2008
New Revision: 56085

URL: http://llvm.org/viewvc/llvm-project?rev=56085&view=rev
Log:
Propagate subreg index when promoting a load to a copy.

Added:
    llvm/trunk/test/CodeGen/X86/2008-09-10-SpillerBug2.ll
Modified:
    llvm/trunk/lib/CodeGen/VirtRegMap.cpp

Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=56085&r1=56084&r2=56085&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original)
+++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Wed Sep 10 20:02:12 2008
@@ -1588,11 +1588,18 @@
             if (DestReg != InReg) {
               const TargetRegisterClass *RC = RegInfo->getRegClass(VirtReg);
               TII->copyRegToReg(MBB, &MI, DestReg, InReg, RC, RC);
+              MachineOperand *DefMO = MI.findRegisterDefOperand(DestReg);
+              unsigned SubIdx = DefMO->getSubReg();
               // Revisit the copy so we make sure to notice the effects of the
               // operation on the destreg (either needing to RA it if it's 
               // virtual or needing to clobber any values if it's physical).
               NextMII = &MI;
               --NextMII;  // backtrack to the copy.
+              // Propagate the sub-register index over.
+              if (SubIdx) {
+                DefMO = NextMII->findRegisterDefOperand(DestReg);
+                DefMO->setSubReg(SubIdx);
+              }
               BackTracked = true;
             } else {
               DOUT << "Removing now-noop copy: " << MI;

Added: llvm/trunk/test/CodeGen/X86/2008-09-10-SpillerBug2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-09-10-SpillerBug2.ll?rev=56085&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/2008-09-10-SpillerBug2.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2008-09-10-SpillerBug2.ll Wed Sep 10 20:02:12 2008
@@ -0,0 +1,40 @@
+; RUN: llvm-as < %s | llc -march=x86 | grep movw | not grep %e.x
+; PR2681
+
+ at g_491 = external global i32		; <i32*> [#uses=1]
+ at g_897 = external global i16		; <i16*> [#uses=1]
+
+define i32 @func_7(i16 signext %p_9) nounwind {
+entry:
+	%p_9.addr = alloca i16		; <i16*> [#uses=2]
+	%l_1122 = alloca i16, align 2		; <i16*> [#uses=1]
+	%l_1128 = alloca i32, align 4		; <i32*> [#uses=1]
+	%l_1129 = alloca i32, align 4		; <i32*> [#uses=1]
+	%l_1130 = alloca i32, align 4		; <i32*> [#uses=1]
+	%tmp14 = load i16* %l_1122		; <i16> [#uses=1]
+	%conv15 = sext i16 %tmp14 to i32		; <i32> [#uses=1]
+	%tmp16 = load i16* %p_9.addr		; <i16> [#uses=1]
+	%conv17 = sext i16 %tmp16 to i32		; <i32> [#uses=1]
+	%xor = xor i32 %conv15, %conv17		; <i32> [#uses=1]
+	%tmp18 = load i32* null		; <i32> [#uses=1]
+	%or = or i32 %xor, %tmp18		; <i32> [#uses=1]
+	%conv19 = trunc i32 %or to i16		; <i16> [#uses=1]
+	%tmp28 = load i16* %p_9.addr		; <i16> [#uses=1]
+	%tmp33 = load i16* @g_897		; <i16> [#uses=1]
+	%tmp34 = load i32* @g_491		; <i32> [#uses=1]
+	%conv35 = trunc i32 %tmp34 to i16		; <i16> [#uses=1]
+	%tmp36 = load i16* null		; <i16> [#uses=1]
+	%conv37 = trunc i16 %tmp36 to i8		; <i8> [#uses=1]
+	%tmp38 = load i32* %l_1128		; <i32> [#uses=1]
+	%conv39 = sext i32 %tmp38 to i64		; <i64> [#uses=1]
+	%tmp42 = load i32* %l_1129		; <i32> [#uses=1]
+	%conv43 = trunc i32 %tmp42 to i16		; <i16> [#uses=1]
+	%tmp44 = load i32* %l_1130		; <i32> [#uses=1]
+	%conv45 = sext i32 %tmp44 to i64		; <i64> [#uses=1]
+	%call46 = call i32 @func_18( i16 zeroext 0, i16 zeroext 0, i16 zeroext %tmp33, i16 zeroext %conv35, i8 zeroext %conv37, i64 %conv39, i32 0, i16 zeroext %conv43, i64 %conv45, i8 zeroext 1 )		; <i32> [#uses=0]
+	%call48 = call i32 @func_18( i16 zeroext 0, i16 zeroext 0, i16 zeroext 0, i16 zeroext 1, i8 zeroext 0, i64 0, i32 1, i16 zeroext %tmp28, i64 0, i8 zeroext 1 )		; <i32> [#uses=0]
+	%call50 = call i32 @func_18( i16 zeroext 1, i16 zeroext 0, i16 zeroext 0, i16 zeroext 1, i8 zeroext 0, i64 0, i32 1, i16 zeroext %conv19, i64 0, i8 zeroext 1 )		; <i32> [#uses=0]
+	ret i32 undef
+}
+
+declare i32 @func_18(i16 zeroext, i16 zeroext, i16 zeroext, i16 zeroext, i8 zeroext, i64, i32, i16 zeroext, i64, i8 zeroext)





More information about the llvm-commits mailing list