summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-02-13 14:55:07 +0000
committerSanjay Patel <spatel@rotateright.com>2018-02-13 14:55:07 +0000
commit907b58530f19d1c5d1e02b0d67e9255f0e70c869 (patch)
treef51c676cac18bfccaabd562c4c075be17bc49081 /llvm
parent35d744d388aa6ab325036f3dfd258b4c39ade1bc (diff)
downloadbcm5719-llvm-907b58530f19d1c5d1e02b0d67e9255f0e70c869.tar.gz
bcm5719-llvm-907b58530f19d1c5d1e02b0d67e9255f0e70c869.zip
[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
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp4
-rw-r--r--llvm/test/CodeGen/X86/undef-ops.ll15
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
+}
+
OpenPOWER on IntegriCloud