This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Add some minor post-selection optimizations.
ClosedPublic

Authored by aemerson on Oct 26 2022, 2:43 PM.

Details

Summary

The first is doing some trivial cross-regclass folding, where we can either
do some extra constraining to eliminate the copy or modify uses to use a smaller
regclass.

The second is that we set the kill flags on vreg use operands if they're the
only use of that vreg.

Both of these cases seem to be done by SelectionDAG's lowering from DAG to
MIs that we currently miss. There are minor code size improvements on average.

Here's the results for -Os on CTMark.

Program                                       size.__text
                                              before         after           diff
tramp3d-v4/tramp3d-v4                         366000.00      366012.00       0.0%
mafft/pairlocalalign                          248196.00      248188.00      -0.0%
7zip/7zip-benchmark                           568612.00      568592.00      -0.0%
kimwitu++/kc                                  434704.00      434676.00      -0.0%
Bullet/bullet                                 456128.00      456096.00      -0.0%
sqlite3/sqlite3                               284136.00      284100.00      -0.0%
ClamAV/clamscan                               381492.00      381396.00      -0.0%
SPASS/SPASS                                   412052.00      411944.00      -0.0%
lencod/lencod                                 428060.00      427912.00      -0.0%
consumer-typeset/consumer-typeset             413148.00      411116.00      -0.5%
                           Geomean difference                               -0.1%

Diff Detail

Event Timeline

aemerson created this revision.Oct 26 2022, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 2:43 PM
aemerson requested review of this revision.Oct 26 2022, 2:43 PM
arsenm added a subscriber: arsenm.Oct 26 2022, 2:44 PM
arsenm added inline comments.
llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp
89

I'd be disappointed if this is actually helping. Do you have examples where kill flags are needed that aren't added by LiveVariables?

paquette added inline comments.Oct 26 2022, 4:14 PM
llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp
94

Doxygen comments should go in the header, right?

108

isPhysical?

132

We need the one-use check here right?

150

I think you can just use explicit_operands() here?

156
aemerson added inline comments.Oct 26 2022, 8:39 PM
llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp
89

Huh, you're right. I'm not sure why I thought this was making an improvement, must have been measuring the wrong change. I'll remove this from the patch.

108

Registers can be either physical, virtual or stack slots apparently, so it's better to use isVirtual().

132

No, if the COPY source register is a subclass of the destination, we can just replace all uses of the dest with the source safely, so we can do it for every use of the COPY's dst.

150

I need Idx for the getOperandConstraint() call below.

aemerson updated this revision to Diff 471006.Oct 26 2022, 8:49 PM

Address comments and remove the kill flags code.

arsenm added inline comments.Oct 26 2022, 11:04 PM
llvm/lib/Target/AArch64/GISel/AArch64PostSelectOptimize.cpp
108

I'm pretty sure the stack slot case only happens transiently in regalloc

aemerson updated this revision to Diff 471035.Oct 27 2022, 12:22 AM

Use isPhysical()

paquette accepted this revision.Nov 1 2022, 3:49 PM
This revision is now accepted and ready to land.Nov 1 2022, 3:49 PM
This revision was landed with ongoing or failed builds.Nov 1 2022, 4:09 PM
This revision was automatically updated to reflect the committed changes.