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

RISC-V: Enable LOGIC_LOGIC instruction fusion

GCC adds support for fusing pairs of logical instructions on RISC-V, enhancing code efficiency.

GCC can now recognize and fuse pairs of logical instructions on RISC-V architectures, such as ANDI, ORI, and XORI, when specific constraints on their destination and source registers are met. This new fusion capability, which reuses existing logic for canonical ANDI operations, is disabled by default and is supported by new test cases.

In Details

This commit introduces the RISCV_FUSE_LOGIC_LOGIC macro-fusion pattern to GCC's RISC-V backend. It enforces destination, dependency, and source-count constraints for logical instructions. The classifier reuses the ANDI classifier for both canonical ANDI and zero-extend RTL forms, allowing for more efficient code generation by combining common logical operations. The fusion is disabled by default, requiring explicit enabling for activation.

For Context
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.
ANDI
A RISC-V instruction that performs a bitwise AND operation between a source register and an immediate value, storing the result in a destination register.
RTL
Register Transfer Language, an intermediate representation used by GCC to describe hardware operations before they are translated into machine code.
Filed Under: risc-voptimizationcompiler