This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Select arithmetic extended register patterns
ClosedPublic

Authored by paquette on Aug 27 2019, 3:09 PM.

Details

Summary

This teaches GISel to select patterns which fold an extend plus optional shift into the addressing mode. In particular, adds and subs.

Factor out the arith extended register ComplexPatterns in AArch64InstrFormats.td and create GISel equivalents.

Add some equivalent functions to the ones in AArch64ISelDAGToDAG:

  • selectArithExtendedRegister
  • narrowExtendRegIfNeeded
  • getExtendTypeForInst

getExtendTypeForInst includes the checks for loads and stores. This will be used for WRO addressing modes in loads + stores.

Teach selectCopy to properly handle subregister copies on the same bank in order to support narrowExtendRegIfNeeded. The extended register must be a GPR32, so we need to support same-bank subregister copies.

Fix a bug in getSubRegForClass which would cause registers on things like GPR32common to end up getting ssub. Just change the check to look for FPR32 rather than GPR32.

For tests:

  • Add select-arith-extended-reg.mir
  • Update addsub_ext.ll to include GlobalISel checks

Diff Detail

Repository
rL LLVM

Event Timeline

paquette created this revision.Aug 27 2019, 3:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2019, 3:09 PM
aemerson added inline comments.Aug 28 2019, 2:20 PM
llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
4590 ↗(On Diff #217508)

DAG?

4601 ↗(On Diff #217508)

This is just doing a normal copy, not a sub register copy. I.e. here ExtReg could be s64 and NarrowReg is a GPR32 RC, which isn't legal.

4658 ↗(On Diff #217508)

We should clean this up to have a GISel equivalent of isDef32() and add G_PHI.

4663 ↗(On Diff #217508)

s/EXTRACT_SUBREG/subregister copy

paquette updated this revision to Diff 217955.Aug 29 2019, 11:58 AM
  • Fix comments
  • Add isDef32
  • Explicitly select the copy into a subregister copy instead of banking on the selector picking it up later
aemerson accepted this revision.Aug 29 2019, 1:44 PM

LGTM with nit.

llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
4675 ↗(On Diff #217955)

I don't think we need the ptrtoint pairs here.

This revision is now accepted and ready to land.Aug 29 2019, 1:44 PM
This revision was automatically updated to reflect the committed changes.