Index: llvm/include/llvm/IR/Instructions.h =================================================================== --- llvm/include/llvm/IR/Instructions.h +++ llvm/include/llvm/IR/Instructions.h @@ -2267,7 +2267,8 @@ int &Index); static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index) { - assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); + assert(isa(Mask->getType()) && + "Shuffle needs vector constant."); SmallVector MaskAsInts; getShuffleMask(Mask, MaskAsInts); return isExtractSubvectorMask(MaskAsInts, NumSrcElts, Index); @@ -2275,6 +2276,11 @@ /// Return true if this shuffle mask is an extract subvector mask. bool isExtractSubvectorMask(int &Index) const { + // Not possible to express a shuffle mask for a scalable vector for this + // case. + if (isa(getType())) + return false; + int NumSrcElts = cast(Op<0>()->getType())->getNumElements(); return isExtractSubvectorMask(ShuffleMask, NumSrcElts, Index); Index: llvm/unittests/IR/InstructionsTest.cpp =================================================================== --- llvm/unittests/IR/InstructionsTest.cpp +++ llvm/unittests/IR/InstructionsTest.cpp @@ -1073,6 +1073,17 @@ EXPECT_FALSE(Id12->isIdentityWithExtract()); EXPECT_FALSE(Id12->isConcat()); delete Id12; + + // Not possible to express shuffle mask for scalable vector for extract + // subvector. + Type *VScaleV4Int32Ty = ScalableVectorType::get(Int32Ty, 4); + ShuffleVectorInst *Id13 = + new ShuffleVectorInst(Constant::getAllOnesValue(VScaleV4Int32Ty), + UndefValue::get(VScaleV4Int32Ty), + Constant::getNullValue(VScaleV4Int32Ty)); + int Index = 0; + EXPECT_FALSE(Id13->isExtractSubvectorMask(Index)); + delete Id13; } TEST(InstructionsTest, GetSplat) {