Author: Cullen Rhodes Date: 2020-12-07T10:42:48Z New Revision: 9b0189655500c30c4ccb0fb5f3ce14a2ac9c6682
URL: https://github.com/llvm/llvm-project/commit/9b0189655500c30c4ccb0fb5f3ce14a2ac9c6682 DIFF: https://github.com/llvm/llvm-project/commit/9b0189655500c30c4ccb0fb5f3ce14a2ac9c6682.diff LOG: [IR] Support scalable vectors in ShuffleVectorInst::increasesLength Since the length of the llvm::SmallVector shufflemask is related to the minimum number of elements in a scalable vector, it is fine to just get the Min field of the ElementCount. This is already done for the similar function changesLength, tests have been added for both. Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D92472 Added: Modified: llvm/include/llvm/IR/Instructions.h llvm/unittests/IR/InstructionsTest.cpp Removed: ################################################################################ diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 4b08de66e398..00ecc2aa7f37 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -2081,8 +2081,9 @@ class ShuffleVectorInst : public Instruction { /// elements than its source vectors. /// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3> bool increasesLength() const { - unsigned NumSourceElts = - cast<FixedVectorType>(Op<0>()->getType())->getNumElements(); + unsigned NumSourceElts = cast<VectorType>(Op<0>()->getType()) + ->getElementCount() + .getKnownMinValue(); unsigned NumMaskElts = ShuffleMask.size(); return NumSourceElts < NumMaskElts; } diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp index f98ef4b52ccd..09260d347840 100644 --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -1083,7 +1083,19 @@ TEST(InstructionsTest, ShuffleMaskQueries) { 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) { _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits