From ebe11477225cc2793b43073bddc17f484839e006 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Fri, 12 Jul 2013 23:08:06 +0000 Subject: Fix a crash in EvaluateInDifferentElementOrder where it would generate an undef vector of the wrong type. LGTM'd by Nick Lewycky on IRC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186224 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 4 +++- test/Transforms/InstCombine/vec_shuffle.ll | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index d43093d831..f3de6e2d5c 100644 --- a/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -732,7 +732,9 @@ InstCombiner::EvaluateInDifferentElementOrder(Value *V, ArrayRef Mask) { } if (!Found) - return UndefValue::get(I->getType()); + return UndefValue::get( + VectorType::get(V->getType()->getScalarType(), Mask.size())); + Value *V = EvaluateInDifferentElementOrder(I->getOperand(0), Mask); return InsertElementInst::Create(V, I->getOperand(1), Builder->getInt32(Index), "", I); diff --git a/test/Transforms/InstCombine/vec_shuffle.ll b/test/Transforms/InstCombine/vec_shuffle.ll index 5ffe6c0437..2adc1c9693 100644 --- a/test/Transforms/InstCombine/vec_shuffle.ll +++ b/test/Transforms/InstCombine/vec_shuffle.ll @@ -185,3 +185,18 @@ define <2 x i8> @test13c(i8 %x1, i8 %x2) { %C = shufflevector <4 x i8> %B, <4 x i8> undef, <2 x i32> ret <2 x i8> %C } + +define void @test14(i16 %conv10) { + %tmp = alloca <4 x i16>, align 8 + %vecinit6 = insertelement <4 x i16> undef, i16 23, i32 3 + store <4 x i16> %vecinit6, <4 x i16>* undef + %tmp1 = load <4 x i16>* undef + %vecinit11 = insertelement <4 x i16> undef, i16 %conv10, i32 3 + %div = udiv <4 x i16> %tmp1, %vecinit11 + store <4 x i16> %div, <4 x i16>* %tmp + %tmp4 = load <4 x i16>* %tmp + %tmp5 = shufflevector <4 x i16> %tmp4, <4 x i16> undef, <2 x i32> + %cmp = icmp ule <2 x i16> %tmp5, undef + %sext = sext <2 x i1> %cmp to <2 x i16> + ret void +} -- cgit v1.2.3