This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Refactor + improve CMN, ADDS, and ADD emit functions
ClosedPublic

Authored by paquette on Sep 11 2020, 10:28 AM.

Details

Summary

These functions were extremely similar:

  • emitADD
  • emitADDS
  • emitCMN

Refactor them a little, introducing a more generic emitInstr function to do most of the work.

Also add support for the immediate + shifted register addressing modes in each of them.

Update select-uaddo.mir to show that selecing ADDS now supports folding immediates + shifts. (I don't think this can impact CMN, because the CMN checks require a G_SUB with a non-constant on the RHS.)

This is around a 0.02% code size improvement on CTMark at -O3.

Diff Detail

Event Timeline

paquette created this revision.Sep 11 2020, 10:28 AM
paquette requested review of this revision.Sep 11 2020, 10:28 AM
aemerson added inline comments.Sep 11 2020, 11:52 AM
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
3864

This looks almost identical to emitADD now, can we refactor once again to keep this logic in a helper and just pass in the OpcTable?

aemerson added inline comments.Sep 11 2020, 11:54 AM
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
3864

Or instead of passing in the table, add an optional parameter to emitADD to use the ADDS opcodes, and make emitADDS a wrapper around it.

paquette updated this revision to Diff 291611.Sep 14 2020, 10:49 AM

Pass the opcode table as a parameter to a helper function

aemerson accepted this revision.Sep 14 2020, 2:50 PM
aemerson added inline comments.
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
181

This needs a more descriptive name and doc for the table, e.g. what the rows and columns mean.

This revision is now accepted and ready to land.Sep 14 2020, 2:50 PM