On 7/15/2026 1:31 AM, wangjue wrote:
From: juewang <[email protected]>

riscv_legitimize_address handled scaled indexed addresses only when
the constant offset fit an I-type immediate.  Large offsets fell back to
generic legalization and could materialize the same base at each
reference.

Use riscv_add_offset for all offsets before adding the scaled index.
This preserves small-offset code generation and exposes large bases to
CSE.

gcc/ChangeLog:

        * config/riscv/riscv.cc (riscv_legitimize_address): Use
        riscv_add_offset for scaled indexed addresses.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/large-frame-indexed-base.c: New test.
        * gcc.target/riscv/small-frame-indexed-base.c: New test.
THanks.  I've pushed this to the trunk.
jeff

Reply via email to