This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add lane moves to PerfectShuffle tables
ClosedPublic

Authored by dmgreen on Apr 8 2022, 6:17 AM.

Details

Summary

This teaches the perfect shuffle tables about lane inserts, that can help reduce the cost of many entries. Many of the shuffle masks are one-away from being correct, and a simple lane move can be a lot simpler than trying to use ext/zip/etc. Because they are not exactly like the other masks handled in the perfect shuffle tables, they require special casing to generate them, with a special InsOp Operator.

The lane to insert into is encoded as the RHSID, and the move from is grabbed from the original mask. This helps reduce the maximum perfect shuffle entry cost to 3, with many more shuffles being generatable in a single instruction.

Diff Detail

Event Timeline

dmgreen created this revision.Apr 8 2022, 6:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 6:17 AM
dmgreen requested review of this revision.Apr 8 2022, 6:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2022, 6:17 AM
SjoerdMeijer accepted this revision.Apr 13 2022, 1:37 AM

Looks reasonable.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
9748–9753

Can you say what V1 and V2 is, or give them some other names.

9792

Don't know what magic number 9 is, or generally what this is doing. But yeah, looking something up in a table, so am guessing something related to the number of items per table entry. There seems to be enough prior art of magic constants, so looks fine.

This revision is now accepted and ready to land.Apr 13 2022, 1:37 AM

Cheers

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
9792

Yeah - 9 is 2 * 4 + 1. i.e each lane of a 2 input v4 shuffle, plus one for undef. It's just how the tables are encoded.

This revision was landed with ongoing or failed builds.Apr 19 2022, 6:49 AM
This revision was automatically updated to reflect the committed changes.
nemanjai added inline comments.
llvm/utils/PerfectShuffle/PerfectShuffle.cpp
317

This is unused and is causing build breaks with -Werror:
https://lab.llvm.org/buildbot/#/builders/57/builds/17025

dmgreen added inline comments.Apr 19 2022, 8:16 AM
llvm/utils/PerfectShuffle/PerfectShuffle.cpp
317

Oh yeah, so it does. I will fix that now. Sorry for not spotting that earlier, this file is really a utility that does need to be part of the build as far as I understand. It's really just a stand-alone cpp file.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp