GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc Performance Win

Use synthesize_add more on RISC-V

Improves RISC-V code generation by using `synthesize_add` for better RTL construction, fixing a regression.

This commit addresses a regression in RISC-V code generation where certain address calculations, particularly those involving offsets in the range [2048..4095], were not optimally synthesized. The changes ensure that the riscv_add_offset function now correctly utilizes synthesize_add when possible, leading to more efficient RTL generation for memory references. This resolves an issue where naive code generation was falling back for these offsets, impacting the ability to combine subsequent instructions.

In Details

A regression introduced in GCC's handling of address calculation offsets on RISC-V led to cases where synthesize_add was bypassed, resulting in suboptimal initial RTL generation for memory accesses. Specifically, offsets in the [2048, 4095] range would cause a fallback to simpler, less optimizable RTL. This patch modifies riscv_add_offset to intercept these cases and correctly invoke synthesize_add, enabling subsequent optimization passes to effectively combine instructions and generate more compact code.

For Context
synthesize_add
A GCC internal function that attempts to generate an RTL (Register Transfer Language) expression for an addition, often optimizing for specific instruction patterns.
RTL (Register Transfer Language)
An intermediate representation used by GCC to describe programs. It's a low-level language that represents operations on registers and memory.
RISC-V
An open-standard instruction set architecture based on Reduced Instruction Set Computing principles.
GIMPLE-RTL phase
A stage in the GCC compilation pipeline where the GIMPLE (Generic Intermediate Representation) code is translated into RTL.
Filed Under: risc-voptimizationrtlregression fix