This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Allocate emergency spillslot when using fixed-length SVE.

Authored by sdesmalen on Mar 7 2023, 5:42 AM.



The SVE reg+imm addressing modes require the immediate to be a multiple
of VL. When it is not a multiple of VL, it can use 0 for the immediate
and use an add instruction to materialise the base-register.

When using SVE instructions to access fixed-length vectors on the stack
that are not VL-aligned, the frame should anticipate that it might require
an emergency spill-slot to accomodate for an extra 'add' to materialize
the base-address of the load when there are no free registers available.


Diff Detail

Unit TestsFailed

Event Timeline

sdesmalen created this revision.Mar 7 2023, 5:42 AM
sdesmalen requested review of this revision.Mar 7 2023, 5:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2023, 5:42 AM
peterwaller-arm accepted this revision.Mar 7 2023, 7:21 AM

Makes sense to me, one minor suggestion. I note that this introduces a few loads/stores to the stack for fixed length vectorization, but having it work correctly is the priority, those may be possible to remove later.


Since this test lacks check lines I presume it is meant to check only that llc exits successfully. Could you have checklines or a comment explaining what failure it is meant to catch?

This revision is now accepted and ready to land.Mar 7 2023, 7:21 AM
sdesmalen updated this revision to Diff 503041.Mar 7 2023, 7:45 AM

Added missing CHECK lines

sdesmalen added inline comments.Mar 7 2023, 7:46 AM

Sorry I forgot to put in the CHECK lines. Thanks for catching this!

paulwalker-arm added inline comments.Mar 7 2023, 10:06 AM

Is this initialisation required?


This seems a bit "belt and braces". You sure there's no other solution?


Is the StackID of this frame index also relevant? As in, you only care about accesses to the non-scalable stack region?

Does using an SVE instruction to access a fixed stack slot ever work? I mean, I guess if you get lucky, the fixed offset is zero, but that should happen rarely. Maybe we'd get better code if we expand out the arithmetic earlier. (Doesn't need to block this patch, just something to think about.)

Matt added a subscriber: Matt.Mar 7 2023, 11:38 AM
sdesmalen abandoned this revision.Mar 16 2023, 7:02 AM

Abandoning since the alternative fix has now landed (D146056)