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

RISC-V adds SRLI_ADD macro-fusion

RISC-V target can now fuse right shift immediate instructions with add operations, improving performance for bit manipulation and arithmetic.

GCC introduces SRLI_ADD macro-fusion recognition for RISC-V, combining right shift immediate (SRLI) instructions with a matching-width ADD-type operation. This optimization applies when the shift amount is small (0-3) and producer-consumer dependencies are met. The fusion reuses existing shift and add classifiers. It is disabled by default, and its positive dump checks are XFAILed, pending CPU enablement.

In Details

This commit adds the RISCV_FUSE_SRLI_ADD rule to the RISC-V fusion engine in riscv-fusion.cc. It targets sequences of SRLI (or SRLIW) followed by an ADD-type instruction when the effective shift amount is between 0 and 3. The implementation reuses riscv_fuse_shift_classifier and the wordness output of riscv_fuse_add_classifier. This pattern is disabled by default and its tests are XFAILed.

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.
SRLI
Shift Right Logical Immediate. An instruction that shifts the bits of a register to the right by a specified immediate amount, filling the vacated bits with zeros.
SRLIW
Shift Right Logical Immediate Word. Similar to SRLI but operates on a word (32 bits on RV64).
ADD-type operation
An arithmetic instruction that adds two operands, such as ADD or ADDI.
XFAIL
A test directive in GCC's testsuite indicating that a test is expected to fail for a specific reason (e.g., a feature is not yet fully supported or enabled). This allows the test to be included without causing the overall test suite to fail.
Filed Under: risc-voptimizationinstruction fusion