Takayuki 'January June' Suwa bba0342a57 xtensa: Apply further improvement to xtensa_legitimize_address()
The load/store instructions in the Xtensa ISA have an unsigned 8-bit
displacement immediate field that scales with the byte width of the
reference.  That is, for a 1-byte reference, the displacement is between
0 and 255, for 2-bytes between 0 and 510, and for 4-bytes between 0 and
1020.

However, xtensa_legitimize_address() has not been able to take advantage
of this fact until now, and has limited the maximum displacement to 255
regardless of the reference byte width.

This patch resolves the above limitation and slightly improves the effi-
ciency of large positive displacements during memory accesses wider than
1-byte.

     /* example */
     int test(short a[]) {
       return a[32767] + a[16511] + a[1];
     }

     ;; before (-O2)
     	.literal_position
     	.literal .LC0, 65534
     test:
     	entry	sp, 32
     	l32r	a8, .LC0
     	addmi	a9, a2, 0x100
     	add.n	a8, a2, a8
     	addmi	a9, a9, 0x7f00
     	l16si	a8, a8, 0	;; 32767 = 65534 / 2
     	l16si	a9, a9, 254	;; 16551 = (32512 + 256 + 254) / 2
     	l16si	a2, a2, 2
     	add.n	a8, a8, a9
     	add.n	a2, a8, a2
     	retw.n

     ;; after (-O2)
     test:
     	entry	sp, 32
     	addmi	a9, a2, 0x7f00	;; CSEd
     	addmi	a8, a9, 0x7f00
     	l16si	a8, a8, 510	;; 32767 = (32512 + 32512 + 510) / 2
     	l16si	a9, a9, 510	;; 16511 = (32512 + 510) / 2
     	l16si	a2, a2, 2
     	add.n	a8, a8, a9
     	add.n	a2, a8, a2
     	retw.n

gcc/ChangeLog:

	* config/xtensa/xtensa.cc (xtensa_legitimize_address):
	Modify to extend the upper limit of the coverable offset if the
	address displacement of the corresponding machine instruction is
	greater than 255.
2026-05-05 01:54:26 -07:00
2026-05-05 00:16:31 +00:00
2026-05-05 00:16:31 +00:00
2026-04-22 00:16:28 +00:00
2026-05-05 00:16:31 +00:00
2026-04-22 00:16:28 +00:00
2026-04-22 00:16:28 +00:00
2026-04-30 00:16:31 +00:00
2026-04-23 00:16:32 +00:00
2026-05-05 00:16:31 +00:00

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.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%