https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116326
--- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Richard Sandiford from comment #2)
> This is caused by the final entry in ELIMINABLE_REGS:
>
> { FRAME_POINTER_REGNUM + 1, STACK_POINTER_REGNUM + 1 }
>
> I guess this was added to work around a reload bug involving multi-register
> pointers, but it shouldn't be necessary for LRA (and as this PR shows, it's
> actively harmful for LRA).
It was due to problems with multi-reg frame-pointer. (AFAIR, using a
hard-frame-poiner besides frame-poiner didn't resolve the issues.)
My problem now is that avr.h has:
#define ELIMINABLE_REGS { \
{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
{ ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM }, \
{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
{ FRAME_POINTER_REGNUM + 1, STACK_POINTER_REGNUM + 1 } }
but ira.cc uses that to initialize a static const array, hence there's no way
to depend that on options I guess?
One solution would be to skip upper parts of multi-part pointers in
elimination. (And maybe other places: TARGET_HARD_REGNO_SCRATCH_OK and
HARD_REGNO_RENAME_OK assume special handling for the high part of multi-reg FP,
too).