This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Allow prelegalizer combiners to have access to LegalizerInfo.
ClosedPublic

Authored by aemerson on Oct 2 2022, 3:08 PM.

Details

Summary

Before, the isPreLegalize() query in CombinerHelper only checked for the
presence of a LegalizerInfo object. This is problematic when we want to have
a combine actually check for legality in a pre-legalizer combine pass, since
if we pass a LegalizerInfo object to the constructor it causes the combines to
think that we're running *post* legalizer, which isn't true.

This change fixes it to instead check an explicit bool that passes to signal
whether the pass will be run before or after legalization.

Doing so exposed a bug in the extending loads combine, which tried to check for
legality of candidate extending loads if LegalizerInfo was present. Since we
only ran it pre-legalizer and therefore with a null LegalizerInfo, it never
actually ran. Also fixes the legality checks to keep the tests passing.

Diff Detail

Event Timeline

aemerson created this revision.Oct 2 2022, 3:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 2 2022, 3:08 PM
aemerson requested review of this revision.Oct 2 2022, 3:08 PM
arsenm accepted this revision.Oct 2 2022, 6:41 PM

LGTM with nit

llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
380–382

Easier to read this out of the CombinerHelper

This revision is now accepted and ready to land.Oct 2 2022, 6:41 PM
aemerson added inline comments.Oct 2 2022, 6:56 PM
llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
380–382

Not sure what you mean?

arsenm added inline comments.Oct 2 2022, 7:11 PM
llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
380–382

Should have a getter for Helper.LI, MI.getParent()->getParent()->getSubtarget().getLegalizerInfo() is really long

aemerson added inline comments.Oct 2 2022, 11:35 PM
llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
380–382

We're trying to construct a CombinerHelper here so we don't have that available yet. I'll shorten it a bit to use MI.getMF() instead.

This revision was landed with ongoing or failed builds.Oct 2 2022, 11:53 PM
This revision was automatically updated to reflect the committed changes.