On Sat, Sep 12, 2026 at 1:12 PM Takayuki 'January June' Suwa <[email protected]> wrote: > > The xtensa_valid_move() function, which is called from locations such as the > condition clause of the "movsi_internal" MD insn pattern, was introduced in > commit 71cc6aea > (about 24 years ago) to prevent a non-register source from being directly > assigned to the stack pointer when the "Windowed Register ABI" is configured > (in such cases, the MOVSP instruction must be used via a scratch register). > > This is likely a workaround for the fact that Reload pass at the time was > too lenient (or loose) with respect to the operand constraints of the insn > pattern, and perhaps register allocation was performed under the assumption > that non-register sources could be assigned to hard registers belonging to > GENERAL_REGS (including the stack pointer in Xtensa). > > However, LRA has now replaced old Reload for the Xtensa target; since both > instruction alternative selection and hard register allocation are performed > in strict adherence to operand constraints, it is no longer necessary to > employ workarounds like the one mentioned above. > > In this case, for example, since there is no alternative that simultaneously > satisfies the constraints for the non-register source (such as a memory > reference) and the stack pointer destination, LRA correctly recognizes and > reloads the source into another scratch address (general-purpose) register. > > Therefore, this patch removes the workaround code mentioned above in > xtensa_valid_move(). > > gcc/ChangeLog: > > * config/xtensa/xtensa.cc (xtensa_valid_move): > Remove code that rejects non-register sources when the destination > is the stack pointer. > > gcc/testsuite: > > * gcc.target/xtensa/MOVSP.c: New test. > --- > gcc/config/xtensa/xtensa.cc | 24 +++++++----------------- > gcc/testsuite/gcc.target/xtensa/MOVSP.c | 12 ++++++++++++ > 2 files changed, 19 insertions(+), 17 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/xtensa/MOVSP.c
Regtested for target=xtensa-linux-uclibc, no new regressions. Committed whole series to master. -- Thanks. -- Max
