This is an archive of the discontinued LLVM Phabricator instance.

[ARM] MVE vector lane interleaving
ClosedPublic

Authored by dmgreen on Feb 1 2021, 11:02 AM.

Details

Summary

MVE does not have a single sext/zext or trunc instruction that takes the bottom half of a vector and extends to a full width, like NEON has with MOVL. Instead it is expected that this happens through top/bottom instructions. So the MVE equivalent VMOVLT/B instructions take either the even or odd elements of the input and extend them to the larger type, producing a vector with half the number of elements each of double the bitwidth. As there is no simple instruction, we often have to expand sext/zext/trunc into a series of lane moves (or stack loads/stores, which we do not do yet).

This pass takes vector code that starts at truncs, looks for interconnected blobs of operations that end with sext/zext and transforms them by adding shuffles so that the lanes are interleaved and the MVE VMOVL/VMOVN instructions can be used. This is done pre-ISel so that it can work across basic blocks.

This initial version of the pass just handles a limited set of instructions, not handling constants or splats or FP, which can all come as extensions to this base.

Diff Detail

Event Timeline

dmgreen created this revision.Feb 1 2021, 11:02 AM
dmgreen requested review of this revision.Feb 1 2021, 11:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2021, 11:02 AM
SjoerdMeijer added inline comments.Feb 16 2021, 8:48 AM
llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp
2

Before I do a 2nd and more in depth review, some name bike shedding: Lane Interleaving.
I am wondering if that is the most accurate description. This pass is about more efficient vector (element) extensions, which is achieved by some reshuffling. But lane interleaving is something that is used under the hood so we can use the bottom/top moves, thus it's not about lane interleaving per se or more efficient codegen for lane interleaving. So, would MVEVectorExtends or something like that be a better description?

81

Nit: perhaps mve should be MVE here.

115

Bike shedding names: looksBeneficial sound a bit uncertain. Perhaps just IsBeneficial or something along those lines.

159

Typo: operantions

Thanks for taking a look.

llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp
2

Lane interleaving sounds like the right name to me. The idea of the pass is to interleave the lanes so that we can use t/b instructions, as the extended vector uses a different lane ordering to the original.
The vector extends are just one way of doing that. There will hopefully be follow up patches for things like constant arrays and interleaving existing shuffles. I was keeping this patch simple though.

dmgreen updated this revision to Diff 324919.Feb 19 2021, 1:43 AM

Fix some typos and bad naming.

SjoerdMeijer accepted this revision.Feb 19 2021, 5:09 AM

Looks like a nice change to me.

llvm/lib/Target/ARM/MVELaneInterleavingPass.cpp
2

Okidoki, sounds good.

128

Nit: not sure what the coding standard says about this case, but perhaps some curly brackets are required for this for-loop and the one below.

200

Nit: if we are only using Ops to avoid revisiting the same instruction, perhaps Seen is a better description.... (see next comment)

226

....because at this point I was curious how else it was used, but don't think it is.

This revision is now accepted and ready to land.Feb 19 2021, 5:09 AM
This revision was automatically updated to reflect the committed changes.