[PATCH] D133671: [GlobalISel][Legalizer] Fix minScalarEltSameAsIf to handle p0 element types.
Amara Emerson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 11 08:31:35 PDT 2022
aemerson created this revision.
aemerson added reviewers: arsenm, paquette, foad, Kai, tschuett.
aemerson added a project: LLVM.
Herald added a subscriber: rovka.
Herald added a project: All.
aemerson requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
The mutation the action generates tries to change the input type into the element type of larger vector type. This doesn't work if the larger element type is a vector since it creates an illegal mutation between scalar and pointer types.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133671
Files:
llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
Index: llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
===================================================================
--- llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
+++ llvm/unittests/CodeGen/GlobalISel/LegalizerInfoTest.cpp
@@ -241,6 +241,7 @@
const LLT v2s64 = LLT::fixed_vector(2, 64);
const LLT p0 = LLT::pointer(0, 32);
+ const LLT v2p0 = LLT::fixed_vector(2, p0);
const LLT v3p0 = LLT::fixed_vector(3, p0);
const LLT v4p0 = LLT::fixed_vector(4, p0);
@@ -427,6 +428,18 @@
EXPECT_ACTION(FewerElements, 0, s16,
LegalityQuery(G_ADD, {LLT::scalable_vector(8, 16)}));
}
+
+ // Test minScalarEltSameAsIf
+ {
+ LegalizerInfo LI;
+ auto &LegacyInfo = LI.getLegacyLegalizerInfo();
+
+ LI.getActionDefinitionsBuilder(G_SELECT).minScalarEltSameAsIf(
+ all(isVector(0), isVector(1)), 1, 0);
+ LegacyInfo.computeTables();
+
+ EXPECT_ACTION(WidenScalar, 1, v2s32, LegalityQuery(G_SELECT, {v2p0, v2s1}));
+ }
}
TEST(LegalizerInfoTest, MMOAlignment) {
Index: llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -1040,6 +1040,8 @@
},
[=](const LegalityQuery &Query) {
LLT T = Query.Types[LargeTypeIdx];
+ if (T.isVector() && T.getElementType().isPointer())
+ T = T.changeElementType(LLT::scalar(T.getScalarSizeInBits()));
return std::make_pair(TypeIdx, T);
});
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133671.459374.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220911/6a198078/attachment.bin>
More information about the llvm-commits
mailing list