[llvm-branch-commits] [llvm] 7b1cb47 - [IR] Bail out for scalable vectors in ShuffleVectorInst::isConcat
Cullen Rhodes via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 7 03:03:25 PST 2020
Author: Cullen Rhodes
Date: 2020-12-07T10:48:35Z
New Revision: 7b1cb4715063679531e51127eee869cd03df88da
URL: https://github.com/llvm/llvm-project/commit/7b1cb4715063679531e51127eee869cd03df88da
DIFF: https://github.com/llvm/llvm-project/commit/7b1cb4715063679531e51127eee869cd03df88da.diff
LOG: [IR] Bail out for scalable vectors in ShuffleVectorInst::isConcat
Shuffle mask for concat can't be expressed for scalable vectors, so we
should bail out. A test has been added that previously crashed, also
tested isIdentityWithPadding and isIdentityWithExtract where we already
bail out.
Reviewed By: sdesmalen
Differential Revision: https://reviews.llvm.org/D92475
Added:
Modified:
llvm/lib/IR/Instructions.cpp
llvm/unittests/IR/InstructionsTest.cpp
Removed:
################################################################################
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<UndefValue>(Op<2>()))
return false;
+ // FIXME: Not currently possible to express a shuffle mask for a scalable
+ // vector for this case.
+ if (isa<ScalableVectorType>(getType()))
+ return false;
+
int NumOpElts = cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
int NumMaskElts = cast<FixedVectorType>(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) {
More information about the llvm-branch-commits
mailing list