From 3ab32ea49ec13182f1397dc89c37551692f67140 Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Sun, 15 Apr 2012 15:08:09 +0000 Subject: [PATCH] When emulating vselect using OR/AND/XOR make sure to bitcast the result back to the original type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154764 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp | 3 ++- test/CodeGen/X86/sse41-blend.ll | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp index 3ae8345bd19..9fe4480d113 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -417,7 +417,8 @@ SDValue VectorLegalizer::ExpandVSELECT(SDValue Op) { Op1 = DAG.getNode(ISD::AND, DL, VT, Op1, Mask); Op2 = DAG.getNode(ISD::AND, DL, VT, Op2, NotMask); - return DAG.getNode(ISD::OR, DL, VT, Op1, Op2); + SDValue Val = DAG.getNode(ISD::OR, DL, VT, Op1, Op2); + return DAG.getNode(ISD::BITCAST, DL, Op.getValueType(), Val); } SDValue VectorLegalizer::ExpandUINT_TO_FLOAT(SDValue Op) { diff --git a/test/CodeGen/X86/sse41-blend.ll b/test/CodeGen/X86/sse41-blend.ll index 78604a0e963..1a1017d2c17 100644 --- a/test/CodeGen/X86/sse41-blend.ll +++ b/test/CodeGen/X86/sse41-blend.ll @@ -80,3 +80,11 @@ define <2 x double> @B(<2 x double> %x, <2 x double> %y) { ret <2 x double> %min } +; CHECK: float_crash +define void @float_crash() nounwind { +entry: + %merge205vector_func.i = select <4 x i1> undef, <4 x double> undef, <4 x double> undef + %extract214vector_func.i = extractelement <4 x double> %merge205vector_func.i, i32 0 + store double %extract214vector_func.i, double addrspace(1)* undef, align 8 + ret void +} -- 2.34.1