diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2629,12 +2629,14 @@ Type *SelectorTy = Type::getInt1Ty(Context); - // The selector might be an i1 or an + // The selector might be an i1, an , or a // Get the type from the ValueList before getting a forward ref. if (VectorType *VTy = dyn_cast(CurTy)) if (Value *V = ValueList[Record[0]]) if (SelectorTy != V->getType()) - SelectorTy = VectorType::get(SelectorTy, VTy->getNumElements()); + SelectorTy = VectorType::get(SelectorTy, + VTy->getNumElements(), + VTy->isScalable()); V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0], SelectorTy), @@ -2692,7 +2694,8 @@ Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy); Type *ShufTy = VectorType::get(Type::getInt32Ty(Context), - OpTy->getNumElements()); + OpTy->getNumElements(), + OpTy->isScalable()); Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); break; @@ -2706,7 +2709,8 @@ Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); Type *ShufTy = VectorType::get(Type::getInt32Ty(Context), - RTy->getNumElements()); + RTy->getNumElements(), + RTy->isScalable()); Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); break; @@ -4167,9 +4171,15 @@ return error("Invalid record"); if (!Vec1->getType()->isVectorTy() || !Vec2->getType()->isVectorTy()) return error("Invalid type for value"); + + bool Vec1IsScalable = cast(Vec1->getType())->isScalable(); + if (Vec1IsScalable != cast(Vec2->getType())->isScalable()) + return error("Vector Scalability mismatch between types"); + I = new ShuffleVectorInst(Vec1, Vec2, Mask); FullTy = VectorType::get(FullTy->getVectorElementType(), - Mask->getType()->getVectorNumElements()); + Mask->getType()->getVectorNumElements(), + Vec1IsScalable); InstructionList.push_back(I); break; }