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

RISC-V generalizes LDPREINCREMENT macro-fusion

RISC-V target's LDPREINCREMENT fusion now handles more addressing modes and data types, improving flexibility and performance.

GCC generalizes the LDPREINCREMENT macro-fusion recognition for RISC-V. The update allows matching non-word ADDI-type in-place address updates followed by scalar loads, supporting register-plus-offset and LO_SUM addresses, as well as self-moves. It also refactors common pre/post-index load/store constraints into a helper function, with specific checks for stores to prevent data register overlap. The changes enhance the compiler’s ability to fuse address calculation with memory loads.

In Details

This commit refactors the indexed memory fusion logic in riscv-fusion.cc by introducing riscv_fuse_indexed_mem_p to handle common pre/post-index load/store checks, including register overlap detection for stores. It then modifies riscv_fuse_ldpreincrement to utilize this helper, broadening its scope to include scalar integer and floating-point loads, register-plus-offset, LO_SUM addresses, and self-moves. This aims to improve instruction scheduling by fusing address updates with loads.

For Context
macro-fusion
A compiler optimization technique where multiple independent machine instructions are combined into a single, more complex instruction. This can improve performance by reducing instruction fetch, decode, and execution overhead.
RISC-V
An open-standard Instruction Set Architecture (ISA) based on Reduced Instruction Set Computer principles. GCC supports various RISC-V profiles and extensions.
LDPREINCREMENT
A pattern where a base address register is updated before being used in a subsequent load operation.
scalar load
A load instruction that fetches a single value (e.g., an integer or floating-point number) from memory.
ADDI-type update
An instruction that adds an immediate value to a register, used here to update a base address before a memory access.
LO_SUM address
A specific addressing mode in RISC-V that combines a base register with an offset that is computed as the sum of two other registers.
register overlap
A situation where two instructions attempt to use or modify the same register, which can lead to incorrect program behavior if not handled properly.
Filed Under: risc-voptimizationinstruction fusion