[PATCH] D151803: [GlobalIsel][X86] Legalize G_BSWAP II
Thorsten via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 10:43:06 PDT 2023
tschuett updated this revision to Diff 527498.
tschuett added a comment.
fix I
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151803/new/
https://reviews.llvm.org/D151803
Files:
llvm/lib/Target/X86/X86LegalizerInfo.cpp
Index: llvm/lib/Target/X86/X86LegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/X86/X86LegalizerInfo.cpp
+++ llvm/lib/Target/X86/X86LegalizerInfo.cpp
@@ -98,6 +98,52 @@
getActionDefinitionsBuilder({G_MEMCPY, G_MEMMOVE, G_MEMSET}).libcall();
+ if (Subtarget.is64Bit()) {
+ getActionDefinitionsBuilder(G_BSWAP)
+ .legalFor({s32, s64})
+ .widenScalarToNextPow2(0, /*Min=*/32)
+ .clampScalar(0, s32, s64);
+
+ if (Subtarget.hasPOPCNT()) {
+ // popcount (POPCNT)
+ getActionDefinitionsBuilder(G_CTPOP)
+ .legalFor({{s16, s16}, {s32, s32}, {s64, s64}})
+ .widenScalarToNextPow2(1, /*Min=*/16)
+ .clampScalar(1, s16, s64);
+ }
+
+ if (Subtarget.hasLZCNT()) {
+ // count leading zeros (LZCNT)
+ getActionDefinitionsBuilder(G_CTLZ)
+ .legalFor({{s16, s16}, {s32, s32}, {s64, s64}})
+ .widenScalarToNextPow2(1, /*Min=*/16)
+ .clampScalar(1, s16, s64);
+ }
+ } else { // 32-bit
+ getActionDefinitionsBuilder(G_BSWAP)
+ .legalIf([=](const LegalityQuery &Query) {
+ // workaround for legalFor
+ return Query.Types[0] == s32;
+ })
+ .widenScalarToNextPow2(0, /*Min=*/32)
+ .clampScalar(0, s32, s32);
+
+ if (Subtarget.hasPOPCNT()) {
+ // popcount
+ getActionDefinitionsBuilder(G_CTPOP)
+ .legalFor({{s16, s16}, {s32, s32}})
+ .widenScalarToNextPow2(1, /*Min=*/16)
+ .clampScalar(1, s16, s32);
+ }
+
+ if (Subtarget.hasLZCNT()) {
+ // count leading zeros (LZCNT)
+ getActionDefinitionsBuilder(G_CTLZ)
+ .legalFor({{s16, s16}, {s32, s32}})
+ .widenScalarToNextPow2(1, /*Min=*/16)
+ .clampScalar(1, s16, s32);
+ }
+ }
LegacyInfo.computeTables();
verify(*STI.getInstrInfo());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151803.527498.patch
Type: text/x-patch
Size: 1835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230601/1f9e18af/attachment.bin>
More information about the llvm-commits
mailing list