Skip to content

Commit 8d53a3c

Browse files
DenisGZMgithub-actions[bot]
authored andcommitted
Automerge: [GISel][Legalizer] Rework changeElementCountTo (NFC) (#158617)
Mutation `changeElementCountTo` now uses `ElementCount`
2 parents 1af0fd3 + 939d3d0 commit 8d53a3c

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ LLVM_ABI LegalizeMutation changeElementCountTo(unsigned TypeIdx,
383383

384384
/// Keep the same scalar or element type as \p TypeIdx, but take the number of
385385
/// elements from \p Ty.
386-
LLVM_ABI LegalizeMutation changeElementCountTo(unsigned TypeIdx, LLT Ty);
386+
LLVM_ABI LegalizeMutation changeElementCountTo(unsigned TypeIdx,
387+
ElementCount EC);
387388

388389
/// Change the scalar size or element size to have the same scalar size as type
389390
/// 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)