This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Overhaul legalization & isel or shifts to select immediate forms
ClosedPublic

Authored by aemerson on Jun 27 2019, 5:23 PM.

Details

Summary

There are two main issues preventing us from generating immediate form shifts:
a) We have partial SelectionDAG imported support for G_ASHR and G_LSHR shift immediate forms, but they currently don't work because the amount type is expected to be an s64 constant, but we only legalize them to have homogenous types.

To deal with this, first we introduce a custom legalizer to *only* custom legalize s32 shifts which have a constant operand into a s64.

There is also an additional artifact combiner to fold zexts(g_constant) to a larger G_CONSTANT if it's legal, a counterpart to the anyext version committed in an earlier patch.

b) For G_SHL the importer can't cope with the pattern. For this I introduced an early selection phase in the arm64 selector to select these forms manually before the tablegen selector pessimizes it to a register-register variant.

@arsenm A minor change to AMDGPU tests because of the new artifact combiner.

Diff Detail

Repository
rL LLVM

Event Timeline

aemerson created this revision.Jun 27 2019, 5:23 PM

I decided to not change the existing AArch64 SelectionDAG patterns to use i32 because there were a few too many places that hard coded it in, in lowering as well as the TableGen.

arsenm added inline comments.Jun 27 2019, 5:33 PM
llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
1135–1137 ↗(On Diff #206970)

This should return the result of constrainSelectedInstRegOperands

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-zext.mir
74–75 ↗(On Diff #206970)

This seems fine. We probably shouldn't be allowing legal s1 constants anyway.

aemerson updated this revision to Diff 207156.Jun 28 2019, 3:21 PM

Address comment and rebase on top of unsigned->Register changes.

paquette accepted this revision.Jul 2 2019, 3:31 PM

LGTM

This revision is now accepted and ready to land.Jul 2 2019, 3:31 PM
This revision was automatically updated to reflect the committed changes.