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
This commit is contained in:
Chris Lattner 2012-01-30 05:34:13 +00:00
parent 90fb059222
commit 0cd0d81492

View File

@ -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<UndefValue>(Mask)) return UndefValue::get(V1->getType());
if (isa<UndefValue>(Mask))
return UndefValue::get(VectorType::get(EltTy, MaskNumElts));
// Don't break the bitcode reader hack.
if (isa<ConstantExpr>(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<Constant*, 32> Result;