GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
riscv

Fix/simplify patterns for masked comparisons against zero

Improves RISC-V patterns for masked comparisons against zero by using X iterators and simplifying RTL.

This commit refines RISC-V patterns for masked comparisons against zero, simplifying the emitted RTL and improving efficiency. By replacing ANYI iterators with X iterators, the patterns now more directly handle the masking operations, avoiding unnecessary subregister operations. This change simplifies the generated code for equality comparisons involving masked registers, potentially leading to more optimal instruction sequences.

In Details

The RISC-V backend's RTL patterns for branch<ANYI:mode>_shiftedarith_equals_zero, branch<ANYI:mode>_shiftedmask_equals_zero, and branch<ANYI:mode>_shiftedarith_<optab>_shifted have been modified. The LLM review identified that using ANYI iterators led to complexities with subregister operations in the split RTL, particularly when the operation was confined to word_mode. This change replaces ANYI with X iterators, which are more appropriate for the word_mode masking operations. This simplifies the split RTL and aligns the patterns more closely with the actual operations perform…

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on modularity, extensibility, and simplicity.
RTL
Register Transfer Language, an intermediate representation used within GCC to describe code transformations and instruction generation.
ANYI
An iterator in GCC's RTL used to match any operand of a specific mode, often implying potential subregister operations or extensions.
X
In the context of GCC RTL iterators, 'X' typically represents a general-purpose operand that matches any mode, often used when specific subregister handling is not required or desired.
word_mode
A machine-dependent mode in GCC representing the natural word size of the target architecture (e.g., 32 bits on a 32-bit system, 64 bits on a 64-bit system).
Filed Under: risc-voptimizationrtl