[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.

llvm-svn: 325010
This commit is contained in:
Sanjay Patel 2018-02-13 14:55:07 +00:00
parent 16c6e1004c
commit ec0afdb0d7
2 changed files with 17 additions and 2 deletions

View File

@ -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:

View File

@ -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
}