forked from OSchip/llvm-project
[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
This commit is contained in:
parent
6bf29dbb15
commit
9b01896555
|
@ -2081,8 +2081,9 @@ public:
|
||||||
/// elements than its source vectors.
|
/// elements than its source vectors.
|
||||||
/// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3>
|
/// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3>
|
||||||
bool increasesLength() const {
|
bool increasesLength() const {
|
||||||
unsigned NumSourceElts =
|
unsigned NumSourceElts = cast<VectorType>(Op<0>()->getType())
|
||||||
cast<FixedVectorType>(Op<0>()->getType())->getNumElements();
|
->getElementCount()
|
||||||
|
.getKnownMinValue();
|
||||||
unsigned NumMaskElts = ShuffleMask.size();
|
unsigned NumMaskElts = ShuffleMask.size();
|
||||||
return NumSourceElts < NumMaskElts;
|
return NumSourceElts < NumMaskElts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1083,7 +1083,19 @@ TEST(InstructionsTest, ShuffleMaskQueries) {
|
||||||
Constant::getNullValue(VScaleV4Int32Ty));
|
Constant::getNullValue(VScaleV4Int32Ty));
|
||||||
int Index = 0;
|
int Index = 0;
|
||||||
EXPECT_FALSE(Id13->isExtractSubvectorMask(Index));
|
EXPECT_FALSE(Id13->isExtractSubvectorMask(Index));
|
||||||
|
EXPECT_FALSE(Id13->changesLength());
|
||||||
|
EXPECT_FALSE(Id13->increasesLength());
|
||||||
delete Id13;
|
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) {
|
TEST(InstructionsTest, GetSplat) {
|
||||||
|
|
Loading…
Reference in New Issue