Shreya Munnangi 304d7359a6 [RISC-V][PR target/120811] Improving address reloads in LRA
In pr120811, we have cases where GCC is emitting an extra addi instruction
instead of using the 12-bit signed-immediate of ld.

addi t1, t1, 1
ld   t1, 0(t1)

This problem occurs when fp -> sp+offset elimination results in an
out-of-range constant and we generate an address reload in LRA using
addsi/adddi expanders.

We've already adjusted the expanders to widen the set of valid operands to
allow more constants for the 2nd input operand. These expanders, rather than
constructing the constant into a register and using an add instruction, will
generate two addi instructions (or shNadd) during initial RTL generation.

We define a new pattern for cases where we need to access the current frame
and the offsets are too large. This gets reasonable code out of LRA in a form
fold-mem-offsets can handle, rather than having to wait for sched2 to do
the height reduction transformation and leaving in the unnecessary add
instruction in the RTL stream.

To avoid the two addi instructions being squashed back together in the
post-reload combine, we remove the adddi3_const_sum_of_two_s12 pattern.

We are seeing about 100 billion dynamic instructions saved which is about 5%
on cactuBSSN and a 2% improvement in performance on the BPI.

	PR target/120811

gcc/

	* config/riscv/riscv.cc (synthesize_add): Exchange constant terms when
	generating addi pairs.
	(synthesize_addsi): Similarly.
	* config/riscv/riscv.md (addptr<mode>3): New define_expand.
	(*add<mode>3_const_sum_of_two_s12): Remove pattern.

gcc/testsuite/

	* gcc.target/riscv/add-synthesis-1.c: Adjust const to fit in range.
	* gcc.target/riscv/pr120811.c: Add new test case.
	* gcc.target/riscv/sum-of-two-s12-const-1.c: Adjust const to fit in range.
2025-10-13 16:15:02 -06:00
2025-06-03 00:18:06 +00:00
2025-10-05 16:50:51 +00:00
2025-10-09 00:21:21 +00:00
2025-08-29 00:19:55 +00:00
2025-06-23 00:16:33 +00:00
2025-10-11 00:21:09 +00:00
2025-01-02 11:59:57 +01:00
2025-10-10 00:21:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-10 00:21:51 +00:00
2025-10-09 00:21:21 +00:00
2025-01-02 11:59:57 +01:00
2025-10-05 16:50:51 +00:00
2025-10-10 00:21:51 +00:00
2025-10-11 00:21:09 +00:00
2025-10-05 16:50:51 +00:00
2025-10-08 00:20:55 +00:00
2025-10-11 00:21:09 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-10-05 16:50:51 +00:00
2025-09-02 00:19:26 +00:00
2025-10-05 16:50:51 +00:00
2025-10-12 00:17:20 +00:00
2025-10-11 11:08:01 +02:00
2024-11-19 12:27:33 +01:00
2025-10-11 11:08:01 +02: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 1.5 GiB
Languages
C++ 30.7%
C 30%
Ada 14.5%
D 6.1%
Go 5.7%
Other 12.5%