diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 10427b22d5d7..5de1addabbe2 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -2274,6 +2274,11 @@ bool ShuffleVectorInst::isConcat() const { isa(Op<2>())) return false; + // FIXME: Not currently possible to express a shuffle mask for a scalable + // vector for this case. + if (isa(getType())) + return false; + int NumOpElts = cast(Op<0>()->getType())->getNumElements(); int NumMaskElts = cast(getType())->getNumElements(); if (NumMaskElts != NumOpElts * 2) diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp index 09260d347840..2c67ff4286e7 100644 --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -1096,6 +1096,17 @@ TEST(InstructionsTest, ShuffleMaskQueries) { EXPECT_TRUE(Id14->changesLength()); EXPECT_TRUE(Id14->increasesLength()); delete Id14; + + // Not possible to express these masks for scalable vectors, make sure we + // don't crash. + ShuffleVectorInst *Id15 = + new ShuffleVectorInst(Constant::getAllOnesValue(VScaleV2Int32Ty), + Constant::getNullValue(VScaleV2Int32Ty), + Constant::getNullValue(VScaleV2Int32Ty)); + EXPECT_FALSE(Id15->isIdentityWithPadding()); + EXPECT_FALSE(Id15->isIdentityWithExtract()); + EXPECT_FALSE(Id15->isConcat()); + delete Id15; } TEST(InstructionsTest, GetSplat) {