[llvm-commits] [llvm] r160260 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.cpp test/CodeGen/X86/2012-07-16-LeaUndef.ll

Nadav Rotem nadav.rotem at intel.com
Mon Jul 16 03:52:25 PDT 2012


Author: nadav
Date: Mon Jul 16 05:52:25 2012
New Revision: 160260

URL: http://llvm.org/viewvc/llvm-project?rev=160260&view=rev
Log:
Fix a bug in the 3-address conversion of LEA when one of the operands is an
undef virtual register. The problem is that ProcessImplicitDefs removes the
definition of the register and marks all uses as undef. If we lose the undef
marker then we get a register which has no def, is not marked as undef. The
live interval analysis does not collect information for these virtual
registers and we crash in later passes.

Together with Michael Kuperstein <michael.m.kuperstein at intel.com>


Added:
    llvm/trunk/test/CodeGen/X86/2012-07-16-LeaUndef.ll
Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=160260&r1=160259&r2=160260&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Jul 16 05:52:25 2012
@@ -2016,6 +2016,13 @@
                         .addReg(Dest, RegState::Define |
                                 getDeadRegState(isDead)),
                         Src, isKill, Src2, isKill2);
+
+      // Preserve undefness of the operands.
+      bool isUndef = MI->getOperand(1).isUndef();
+      bool isUndef2 = MI->getOperand(2).isUndef();
+      NewMI->getOperand(1).setIsUndef(isUndef);
+      NewMI->getOperand(3).setIsUndef(isUndef2);
+
       if (LV && isKill2)
         LV->replaceKillInstruction(Src2, MI, NewMI);
       break;

Added: llvm/trunk/test/CodeGen/X86/2012-07-16-LeaUndef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-07-16-LeaUndef.ll?rev=160260&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2012-07-16-LeaUndef.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2012-07-16-LeaUndef.ll Mon Jul 16 05:52:25 2012
@@ -0,0 +1,16 @@
+; RUN: llc < %s -march=x86-64 -mcpu=corei7
+
+define void @autogen_SD2543() {
+A:
+  %E83 = add i32 0, 1
+  %E820 = add i32 0, undef
+  br label %C
+C:
+  %B908 = add i32 %E83, %E820
+  store i32 %B908, i32* undef
+  %Sl2391 = select i1 undef, i32 undef, i32 %E83
+  %Cmp3114 = icmp ne i32 %Sl2391, undef
+  br i1 %Cmp3114, label %C, label %G
+G:
+  ret void
+}





More information about the llvm-commits mailing list