[llvm] r186224 - Fix a crash in EvaluateInDifferentElementOrder where it would generate an

Joey Gouly joey.gouly at arm.com
Fri Jul 12 16:08:07 PDT 2013


Author: joey
Date: Fri Jul 12 18:08:06 2013
New Revision: 186224

URL: http://llvm.org/viewvc/llvm-project?rev=186224&view=rev
Log:
Fix a crash in EvaluateInDifferentElementOrder where it would generate an
undef vector of the wrong type.

LGTM'd by Nick Lewycky on IRC.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
    llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=186224&r1=186223&r2=186224&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Fri Jul 12 18:08:06 2013
@@ -732,7 +732,9 @@ InstCombiner::EvaluateInDifferentElement
       }
 
       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);

Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll?rev=186224&r1=186223&r2=186224&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Fri Jul 12 18:08:06 2013
@@ -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> <i32 0, i32 2>
   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> <i32 2, i32 0>
+  %cmp = icmp ule <2 x i16> %tmp5, undef
+  %sext = sext <2 x i1> %cmp to <2 x i16>
+  ret void
+}





More information about the llvm-commits mailing list