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;