[llvm] 333de69 - [IR] Disallow scalable vectors in ShuffleVectorInst::isExtractSubvectorMask

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 03:31:31 PST 2020


Author: Cullen Rhodes
Date: 2020-12-04T11:30:51Z
New Revision: 333de690ea730abd3b23945c0605ebda290ce1b7

URL: https://github.com/llvm/llvm-project/commit/333de690ea730abd3b23945c0605ebda290ce1b7
DIFF: https://github.com/llvm/llvm-project/commit/333de690ea730abd3b23945c0605ebda290ce1b7.diff

LOG: [IR] Disallow scalable vectors in ShuffleVectorInst::isExtractSubvectorMask

It's not possible to express an extract subvector shuffle mask for
a scalable vector.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D92312

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 eb855972256b..4b08de66e398 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -2268,6 +2268,10 @@ class ShuffleVectorInst : public Instruction {
   static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts,
                                      int &Index) {
     assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");
+    // Not possible to express a shuffle mask for a scalable vector for this
+    // case.
+    if (isa<ScalableVectorType>(Mask->getType()))
+      return false;
     SmallVector<int, 16> MaskAsInts;
     getShuffleMask(Mask, MaskAsInts);
     return isExtractSubvectorMask(MaskAsInts, NumSrcElts, Index);
@@ -2275,6 +2279,11 @@ class ShuffleVectorInst : public Instruction {
 
   /// 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<ScalableVectorType>(getType()))
+      return false;
+
     int NumSrcElts =
         cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
     return isExtractSubvectorMask(ShuffleMask, NumSrcElts, Index);

diff  --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp
index b2cfa891dcca..f98ef4b52ccd 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -1073,6 +1073,17 @@ TEST(InstructionsTest, ShuffleMaskQueries) {
   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) {


        


More information about the llvm-commits mailing list