This is an archive of the discontinued LLVM Phabricator instance.

[ARM] One-off identity shuffle
ClosedPublic

Authored by dmgreen on Jan 27 2021, 11:16 AM.

Details

Summary

A One-Off Identity mask is a shuffle that is mostly an identity mask from as single source but contains a single element out-of-place, either from a different vector or from another position in the same vector. As opposed to lowering this via a ARMISD::BUILD_VECTOR we can generate an extract/insert pair directly. Under ARM with individually accessible lane elements this often becomes a simple lane move.

This also alters the LowerVECTOR_SHUFFLEUsingMovs code to use v4f32 (not v4i32), a more natural type for lane moves.

Diff Detail

Event Timeline

dmgreen created this revision.Jan 27 2021, 11:16 AM
dmgreen requested review of this revision.Jan 27 2021, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2021, 11:16 AM
SjoerdMeijer added inline comments.Feb 8 2021, 1:23 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
8197–8198

Why are we changing this into v4f32?

Thanks for talking a look

llvm/lib/Target/ARM/ARMISelLowering.cpp
8197–8198

A v4f32 is a more natural type for lane moves, which is what this is essentially doing. We are moving s registers around, with are naturally f32's.

SjoerdMeijer added inline comments.Feb 8 2021, 7:09 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
8246

nit: shorter is:

for (int i = 0; i < Mask.size(); ++i)
8247

Do we have a test for this? Might have missed it, but didn't see one I think.

dmgreen added inline comments.Feb 8 2021, 7:59 AM
llvm/lib/Target/ARM/ARMISelLowering.cpp
8246

I believe this is how llvm specifies this should be. So we only evaluate Mask.size() once. Apparently I got it from here:
https://github.com/llvm/llvm-project/blob/73aa09704a4c85b097d5fab986ead27092ecc9f7/llvm/lib/IR/Instructions.cpp#L2131

8247

For undef elements? Yeah they will be tested as a part of the vld3 and shuffle3steptype tests I believe, but I'll make sure there are specific tests.

dmgreen updated this revision to Diff 322115.Feb 8 2021, 8:07 AM

Rebase and add some undef mask element tests.

SjoerdMeijer accepted this revision.Feb 8 2021, 8:23 AM

Thanks, LGTM

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