From: Chris Lattner Date: Mon, 30 Jan 2012 05:34:13 +0000 (+0000) Subject: Fix ConstantFoldShuffleVectorInstruction to properly handle the case X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0cd0d8149278782aaa93c190f81e04f10a4efb5e;p=oota-llvm.git Fix ConstantFoldShuffleVectorInstruction to properly handle the case when the result type has a different # elements than the input vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149221 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 36bd4aba4b1..f73e7a76d1a 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -794,15 +794,17 @@ Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val, Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, Constant *Mask) { + unsigned MaskNumElts = Mask->getType()->getVectorNumElements(); + Type *EltTy = V1->getType()->getVectorElementType(); + // Undefined shuffle mask -> undefined value. - if (isa(Mask)) return UndefValue::get(V1->getType()); + if (isa(Mask)) + return UndefValue::get(VectorType::get(EltTy, MaskNumElts)); // Don't break the bitcode reader hack. if (isa(Mask)) return 0; - unsigned MaskNumElts = Mask->getType()->getVectorNumElements(); unsigned SrcNumElts = V1->getType()->getVectorNumElements(); - Type *EltTy = V1->getType()->getVectorElementType(); // Loop over the shuffle mask, evaluating each element. SmallVector Result;