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

RISC-V: Convert define_insn_and_split to simpler define_split.

RISC-V bit manipulation instruction pattern converted to a simpler define_split for better optimization.

This commit converts a RISC-V define_insn_and_split pattern for the andi_add.uw instruction to a simpler define_split. This change is necessary because define_insn_and_split patterns are processed later in the compilation pipeline, preventing early optimization opportunities. By using a define_split, the compiler can now potentially optimize away redundant operations, such as duplicate andi instructions, that were previously missed.

In Details

The andi_add.uw instruction pattern in gcc/config/riscv/bitmanip.md has been converted from define_insn_and_split to define_split. This change addresses PR target/128420 by enabling the compiler's optimization passes to better analyze and potentially eliminate redundant computations. Using define_split allows the pattern's expansion to be visible earlier in the optimization pipeline, facilitating common subexpression elimination and other peephole optimizations that were previously hindered by the lateness of define_insn_and_split.

For Context
define_insn_and_split
A GCC internal macro used in machine description files to define instruction patterns that can be matched and expanded into a sequence of simpler operations.
define_split
A GCC internal macro, similar to define_insn_and_split, but typically used for patterns that are expanded earlier in the compilation pipeline, allowing for more aggressive optimization.
RISC-V
An open-standard instruction set architecture based on Reduced Instruction Set Computing principles.
andi_add.uw
A specific RISC-V instruction pattern likely involving a bitwise AND followed by an addition, potentially with unsigned widening.
Optimization Passes
Distinct stages in the compiler that analyze and transform the intermediate representation of the code to improve its performance, size, or other characteristics.
Filed Under: risc-voptimizationcodegen