Note that the builders are protected by is64Bit().
More fine-grained availibility checks.
Differential D150790
[GlobalIsel][X86] fix legalization of G_CTLZ and G_CTPOP tschuett on May 17 2023, 8:38 AM. Authored by
Details Note that the builders are protected by is64Bit(). More fine-grained availibility checks.
Diff Detail
Event Timeline
Comment Actions That will need larger refactorings. I have already run into this issue. You cannot have two getActionDefinitionsBuilder with the same operation. If I add popcount to setLegalizerInfo32bit, then the builder will be called twice with the same operation: once for 32 and once for 64 bit. Comment Actions if (Subtarget.hasAVX512()) { } else if (Subtarget.is64Bit()) { } else if (Subtarget.is32Bit()) { } Comment Actions It might be separate setLegalizerInfo32bit / setLegalizerInfo64bit isn't actually useful Comment Actions That is not what currently is happening. setLegalizerInfo32bit(); setLegalizerInfo64bit(); setLegalizerInfoSSE1(); setLegalizerInfoSSE2(); setLegalizerInfoSSE41(); setLegalizerInfoSSE42(); setLegalizerInfoAVX(); setLegalizerInfoAVX2(); setLegalizerInfoAVX512(); setLegalizerInfoAVX512DQ(); setLegalizerInfoAVX512BW(); Therefore, I propose the if statements over the features. Comment Actions Btw, I am only interested in correctness and low hanging fruit. Coverage is a different issue. Comment Actions if (Subtarget.hasAVX512() && Subtarget.is64Bit()) { // DQ, BW and VLX } else if (Subtarget.hasAVX2() && Subtarget.is64Bit()) { } else if (Subtarget.hasAVX() && Subtarget.is64Bit()) { } else if (Subtarget.hasSSE41() && Subtarget.is64Bit()) { } else if (Subtarget.hasSSE2() && Subtarget.is64Bit()) { } else if (Subtarget.hasSSE1() && Subtarget.is64Bit()) { } else if (Subtarget.is64Bit()) { } else if (Subtarget.is32Bit()) { } Then you don't run in the existing issues of trying to legalize an operation with different features resp. bit width.
Comment Actions I looked at the AArch64 legalizer. The use if-statements when they have different features.
Comment Actions LGTM as the SSE42 -> POPCNT/LZCNT fix - assuming you're going to do the legalIf() followup |
We need to split this - with just s64 legality here and s16/s32 in setLegalizerInfo32bit above
And just widen sub 32 cases to s32