Aligning stack offsets for spills
Tue Jun 8 15:56:04 GMT 2021
On Tue, 8 Jun 2021, Jeff Law wrote:
> On 6/8/2021 9:06 AM, H.J. Lu wrote:
> > On Tue, Jun 8, 2021 at 7:56 AM Jakub Jelinek via Gcc-patches
> > <firstname.lastname@example.org> wrote:
> >> On Tue, Jun 08, 2021 at 08:47:26AM -0600, Jeff Law wrote:
> >>>> Why is the machinery involving STACK_SLOT_ALIGNMENT and
> >>>> spill_slot_alignment() (for spilling) or get_stack_local_alignment() (for
> >>>> backing stack slots) not working for you? If everything is setup
> >>>> correctly the input alignment to try_fit_stack_local ought to be correct
> >>>> already.
> >>> We don't need the MEM as a whole aligned, just the offset in the address
> >>> calculation due to how we encode those instructions. If I've read that
> >>> code
> >>> correctly, it would arrange for a dynamic realignment of the stack so
> >>> that
> >>> it could then align the slot. None of that is necessary for us and we'd
> >>> like
> >>> to avoid forcing the dynamic stack realignment. Or did I misread the
> >>> code?
> >> I think dynamic stack realignment is done only on x86, no other backend has
> > I believe that all pieces of infrastructure to realign the stack are
> > in place. You
> > just need to properly align the stack in the backend.
> As I've stated, we don't need the stack aligned to these higher boundaries.
> Nor do we need the slot as a whole aligned. That's ultimately just wasteful
> since we don't need them. We just want to get an aligned offset.
Well, but isn't that creating a difference when there is none? You need
an aligned offset; when given an aligned stack pointer that then is
equivalent to an aligned stack address. You are saying that you don't
need the aligned stack pointer, sure, but would it be a problem for you?
Apart from that: dynamic stack realignment can be disabled (or probably
isn't enabled for your target to start with), then the stack offset
alignment machinery should still work in isolation. (Well it might
generate alignment claims in MEM RTL which then isn't in fact true,
depends on the architecture if that's a problem for you).
Either way, I think whatever you need should probably be somehow
integrated with the existing stack slot alignment knobs. Or rather the
two orthogonal pieces (stack pointer alignment and stack offset alignment)
be separated and you then using only the latter.
(Btw: are you also trying to improve non-stack addresses? Because
ultimately your constraints aren't about stack at all but about all
address forms. In a way this all is more like a job for addressing
mode selection and massaging, but of course our support for such in GCC is
limited beyond avoiding invalid modes by reloading into registers, which
is exactly what you don't want :) )
More information about the Gcc-patches