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.
This directory contains the GNU Compiler Collection (GCC).
The GNU Compiler Collection is free software. See the files whose
names start with COPYING for copying permission. The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.
The directory INSTALL contains copies of the installation information
as HTML and plain text. The source of this information is
gcc/doc/install.texi. The installation information includes details
of what is included in the GCC sources and what files GCC installs.
See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information. An online readable
version of the manual is in the files gcc/doc/gcc.info*.
See http://gcc.gnu.org/bugs/ for how to report bugs usefully.
Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.