diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/undef-ops.ll | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 2ece6a82f6c..0dabfdf374e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4667,7 +4667,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT, 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 Opcode, const SDLoc &DL, EVT VT, 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: diff --git a/llvm/test/CodeGen/X86/undef-ops.ll b/llvm/test/CodeGen/X86/undef-ops.ll index 1ed1ec18e1d..257238fe249 100644 --- a/llvm/test/CodeGen/X86/undef-ops.ll +++ b/llvm/test/CodeGen/X86/undef-ops.ll @@ -443,3 +443,18 @@ define <4 x i32> @xor_undef_lhs_vec(<4 x i32> %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 +} + |