Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ LLVM_ABI LegalizeMutation changeElementCountTo(unsigned TypeIdx,

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

/// Change the scalar size or element size to have the same scalar size as type
/// index \p FromIndex. Unlike changeElementTo, this discards pointer types and
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/CodeGen/GlobalISel/LegalizeMutations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ LegalizeMutation LegalizeMutations::changeElementCountTo(unsigned TypeIdx,
}

LegalizeMutation LegalizeMutations::changeElementCountTo(unsigned TypeIdx,
LLT NewEltTy) {
ElementCount EC) {
return [=](const LegalityQuery &Query) {
const LLT OldTy = Query.Types[TypeIdx];
ElementCount NewEltCount = NewEltTy.isVector() ? NewEltTy.getElementCount()
: ElementCount::getFixed(1);
return std::make_pair(TypeIdx, OldTy.changeElementCount(NewEltCount));
return std::make_pair(TypeIdx, OldTy.changeElementCount(EC));
};
}

Expand Down
14 changes: 8 additions & 6 deletions llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,14 @@ TEST(LegalizerInfoTest, RuleSets) {

// Raw type form
LI.getActionDefinitionsBuilder(G_ADD)
.fewerElementsIf(typeIs(0, v4s32), changeElementCountTo(0, v2s32))
.fewerElementsIf(typeIs(0, v8s32), changeElementCountTo(0, s32))
.fewerElementsIf(typeIs(0, LLT::scalable_vector(4, 16)),
changeElementCountTo(0, LLT::scalable_vector(2, 16)))
.fewerElementsIf(typeIs(0, LLT::scalable_vector(8, 16)),
changeElementCountTo(0, s16));
.fewerElementsIf(typeIs(0, v4s32),
changeElementCountTo(0, ElementCount::getFixed(2)))
.fewerElementsIf(typeIs(0, v8s32),
changeElementCountTo(0, ElementCount::getFixed(1)))
.fewerElementsIf(typeIs(0, LLT::scalable_vector(4, s16)),
changeElementCountTo(0, ElementCount::getScalable(2)))
.fewerElementsIf(typeIs(0, LLT::scalable_vector(8, s16)),
changeElementCountTo(0, ElementCount::getFixed(1)));

LegacyInfo.computeTables();

Expand Down
Loading