[llvm] r325010 - [DAG] fix type of undef returned by getNode()

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 06:55:07 PST 2018


Author: spatel
Date: Tue Feb 13 06:55:07 2018
New Revision: 325010

URL: http://llvm.org/viewvc/llvm-project?rev=325010&view=rev
Log:
[DAG] fix type of undef returned by getNode()

The bug has been lying dormant, but apparently was never exposed, until
after rL324941 because we didn't return the correct result 
for shifts with undef operands.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/trunk/test/CodeGen/X86/undef-ops.ll

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=325010&r1=325009&r2=325010&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Feb 13 06:55:07 2018
@@ -4667,7 +4667,7 @@ SDValue SelectionDAG::getNode(unsigned O
       case ISD::FSUB:
       case ISD::FDIV:
       case ISD::FREM:
-        return N1;     // fold op(undef, arg2) -> undef
+        return getUNDEF(VT);     // fold op(undef, arg2) -> undef
       case ISD::UDIV:
       case ISD::SDIV:
       case ISD::UREM:
@@ -4700,7 +4700,7 @@ SDValue SelectionDAG::getNode(unsigned O
     case ISD::SRA:
     case ISD::SRL:
     case ISD::SHL:
-      return N2;       // fold op(arg1, undef) -> undef
+      return getUNDEF(VT);       // fold op(arg1, undef) -> undef
     case ISD::FADD:
     case ISD::FSUB:
     case ISD::FMUL:

Modified: llvm/trunk/test/CodeGen/X86/undef-ops.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/undef-ops.ll?rev=325010&r1=325009&r2=325010&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/undef-ops.ll (original)
+++ llvm/trunk/test/CodeGen/X86/undef-ops.ll Tue Feb 13 06:55:07 2018
@@ -443,3 +443,18 @@ define <4 x i32> @xor_undef_lhs_vec(<4 x
   ret <4 x i32> %r
 }
 
+; This would crash because the shift amount is an i8 operand,
+; but the result of the shift is i32. We can't just propagate
+; the existing undef as the result.
+
+define i1 @undef_operand_size_not_same_as_result() {
+; CHECK-LABEL: undef_operand_size_not_same_as_result:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    retq
+  %sh = shl i32 7, undef
+  %cmp = icmp eq i32 0, %sh
+  ret i1 %cmp
+}
+




More information about the llvm-commits mailing list