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

RISC-V: Improves selection between -1 and constants for conditional zeroing

New RISC-V instruction split improves conditional zeroing performance.

This commit introduces a new define_split for the RISC-V architecture to optimize the selection between -1 and a constant value, particularly for conditional zeroing operations. The change refactors existing patterns to use a more efficient instruction sequence, reducing instruction count. Benchmarks on x264 show significant instruction savings, although further improvements might be possible.

In Details

This patch adds a define_split to config/riscv/zicond.md to optimize the selection between -1 and a constant operand, specifically targeting conditional zeroing. It replaces a multi-instruction sequence with a more compact one, improving code density and potentially performance. The commit notes that this is an improvement over a previous approach and that further work on related PRs (like pr126914) is pending. Tested on riscv32/64-elf.

For Context
RISC-V
A free and open instruction set architecture (ISA) that is gaining traction in embedded systems and high-performance computing.
define_split
A GCC internal mechanism allowing complex RTL (Register Transfer Language) instructions to be broken down into simpler ones during optimization.
RTX
Register Transfer Language, an intermediate representation used in GCC that describes operations on registers and memory.
conditional zeroing
An operation that sets a register to zero based on a condition, often implemented using specific instructions like czero on RISC-V.
Filed Under: risc-voptimizationperformance