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

RISC-V: Recognize SLLI/SRLI instruction fusion

GCC now recognizes and fuses certain SLLI/SRLI instruction pairs on RISC-V, potentially improving performance.

GCC has gained the ability to recognize and fuse specific pairs of SLLI (shift left logical) and SRLI (shift right logical) instructions on RISC-V architectures. This optimization aims to combine these operations when they have the necessary register dependencies, potentially reducing instruction count and improving execution speed. The new fusion logic is disabled by default and includes new test cases.

In Details

This change introduces a new macro-fusion pattern, RISCV_FUSE_SLLI_SRLI, in GCC's RISC-V backend. It utilizes shared shift-pair matching logic, previously refactored in commit 1f2794c98059b452a7d5947e7a5e6e587eefde53, to identify and combine SLLI/SRLI (and their W variants) when the destination register of the first instruction is a source for the second. This builds upon the recent efforts to generalize and refine macro-fusion recognizers for RISC-V, enabling more sophisticated instruction combining.

For Context
SLLI
Shift Left Logical, a RISC-V instruction that shifts bits to the left by a specified immediate or register value.
SRLI
Shift Right Logical, a RISC-V instruction that shifts bits to the right by a specified immediate or register value, filling the leftmost bits with zeros.
macro-fusion
An optimization technique where the compiler combines two or more adjacent instructions into a single, more efficient instruction or sequence, provided specific conditions (like register dependencies) are met.
RISC-V
An open-standard instruction set architecture (ISA) based on modularity, extensibility, and simplicity, gaining traction in embedded systems and high-performance computing.
register dependency
A condition where an instruction requires the output (result) of a previous instruction as one of its inputs.
Filed Under: risc-voptimizationcompiler