Index: llvm/include/llvm/IR/Instructions.h =================================================================== --- llvm/include/llvm/IR/Instructions.h +++ llvm/include/llvm/IR/Instructions.h @@ -2081,8 +2081,9 @@ /// elements than its source vectors. /// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3> bool increasesLength() const { - unsigned NumSourceElts = - cast(Op<0>()->getType())->getNumElements(); + unsigned NumSourceElts = cast(Op<0>()->getType()) + ->getElementCount() + .getKnownMinValue(); unsigned NumMaskElts = ShuffleMask.size(); return NumSourceElts < NumMaskElts; } Index: llvm/unittests/IR/InstructionsTest.cpp =================================================================== --- llvm/unittests/IR/InstructionsTest.cpp +++ llvm/unittests/IR/InstructionsTest.cpp @@ -1083,7 +1083,19 @@ Constant::getNullValue(VScaleV4Int32Ty)); int Index = 0; EXPECT_FALSE(Id13->isExtractSubvectorMask(Index)); + EXPECT_FALSE(Id13->changesLength()); + EXPECT_FALSE(Id13->increasesLength()); delete Id13; + + // Result has twice as many operands. + Type *VScaleV2Int32Ty = ScalableVectorType::get(Int32Ty, 2); + ShuffleVectorInst *Id14 = + new ShuffleVectorInst(Constant::getAllOnesValue(VScaleV2Int32Ty), + UndefValue::get(VScaleV2Int32Ty), + Constant::getNullValue(VScaleV4Int32Ty)); + EXPECT_TRUE(Id14->changesLength()); + EXPECT_TRUE(Id14->increasesLength()); + delete Id14; } TEST(InstructionsTest, GetSplat) {