Skip to content

Commit 9a366d1

Browse files
committed
changeElementCount
1 parent 70a2cd9 commit 9a366d1

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ LegalizeMutation changeElementCountTo(unsigned TypeIdx, unsigned FromTypeIdx);
374374

375375
/// Keep the same scalar or element type as \p TypeIdx, but take the number of
376376
/// elements from \p Ty.
377-
LegalizeMutation changeElementCountTo(unsigned TypeIdx, LLT Ty);
377+
LegalizeMutation changeElementCountTo(unsigned TypeIdx, ElementCount EC);
378378

379379
/// Change the scalar size or element size to have the same scalar size as type
380380
/// index \p FromIndex. Unlike changeElementTo, this discards pointer types and

llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ LegalizeMutation LegalizeMutations::changeElementCountTo(unsigned TypeIdx,
5555
}
5656

5757
LegalizeMutation LegalizeMutations::changeElementCountTo(unsigned TypeIdx,
58-
LLT NewEltTy) {
58+
ElementCount EC) {
5959
return [=](const LegalityQuery &Query) {
6060
const LLT OldTy = Query.Types[TypeIdx];
61-
ElementCount NewEltCount = NewEltTy.isVector() ? NewEltTy.getElementCount()
62-
: ElementCount::getFixed(1);
63-
return std::make_pair(TypeIdx, OldTy.changeElementCount(NewEltCount));
61+
return std::make_pair(TypeIdx, OldTy.changeElementCount(EC));
6462
};
6563
}
6664

llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,14 @@ TEST(LegalizerInfoTest, RuleSets) {
420420

421421
// Raw type form
422422
LI.getActionDefinitionsBuilder(G_ADD)
423-
.fewerElementsIf(typeIs(0, v4s32), changeElementCountTo(0, v2s32))
424-
.fewerElementsIf(typeIs(0, v8s32), changeElementCountTo(0, s32))
425-
.fewerElementsIf(typeIs(0, LLT::scalable_vector(4, 16)),
426-
changeElementCountTo(0, LLT::scalable_vector(2, 16)))
427-
.fewerElementsIf(typeIs(0, LLT::scalable_vector(8, 16)),
428-
changeElementCountTo(0, s16));
423+
.fewerElementsIf(typeIs(0, v4s32),
424+
changeElementCountTo(0, ElementCount::getFixed(2)))
425+
.fewerElementsIf(typeIs(0, v8s32),
426+
changeElementCountTo(0, ElementCount::getFixed(1)))
427+
.fewerElementsIf(typeIs(0, LLT::scalable_vector(4, s16)),
428+
changeElementCountTo(0, ElementCount::getScalable(2)))
429+
.fewerElementsIf(typeIs(0, LLT::scalable_vector(8, s16)),
430+
changeElementCountTo(0, ElementCount::getFixed(1)));
429431

430432
LegacyInfo.computeTables();
431433

0 commit comments

Comments
 (0)