Skip to content

Commit

Permalink
[GlobalIsel][X86] Move G_SHL/G_LSHR/G_ASHR legalization before legacy…
Browse files Browse the repository at this point in the history
… handling and merge 32-bit/64-bit handling
  • Loading branch information
RKSimon committed Jun 2, 2023
1 parent d01ddfe commit 6d8f889
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions llvm/lib/Target/X86/X86LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI,
})
.clampScalar(0, s8, sMaxScalar);

// integer shifts
getActionDefinitionsBuilder({G_SHL, G_LSHR, G_ASHR})
.legalIf([=](const LegalityQuery &Query) -> bool {
return typePairInSet(0, 1, {{s8, s8}, {s16, s8}, {s32, s8}})(Query) ||
(Is64Bit && typePairInSet(0, 1, {{s64, s8}})(Query));
})
.clampScalar(0, s8, sMaxScalar)
.clampScalar(1, s8, s8);

// bswap
getActionDefinitionsBuilder(G_BSWAP)
.legalIf([=](const LegalityQuery &Query) {
Expand Down Expand Up @@ -245,13 +254,6 @@ void X86LegalizerInfo::setLegalizerInfo32bit() {
.widenScalarToNextPow2(0, /*Min*/ 8);
getActionDefinitionsBuilder(G_INTTOPTR).legalFor({{p0, s32}});

// Shifts
getActionDefinitionsBuilder(
{G_SHL, G_LSHR, G_ASHR})
.legalFor({{s8, s8}, {s16, s8}, {s32, s8}})
.clampScalar(0, s8, s32)
.clampScalar(1, s8, s8);

// Comparison
getActionDefinitionsBuilder(G_ICMP)
.legalForCartesianProduct({s8}, {s8, s16, s32, p0})
Expand Down Expand Up @@ -357,13 +359,6 @@ void X86LegalizerInfo::setLegalizerInfo64bit() {
.clampScalar(1, s32, s64)
.widenScalarToNextPow2(1);

// Shifts
getActionDefinitionsBuilder(
{G_SHL, G_LSHR, G_ASHR})
.legalFor({{s8, s8}, {s16, s8}, {s32, s8}, {s64, s8}})
.clampScalar(0, s8, s64)
.clampScalar(1, s8, s8);

// Merge/Unmerge
LegacyInfo.setAction({G_MERGE_VALUES, s128}, LegacyLegalizeActions::Legal);
LegacyInfo.setAction({G_UNMERGE_VALUES, 1, s128},
Expand Down

0 comments on commit 6d8f889

Please sign in to comment.