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

Fix mode goofs in RISC-V's bitmanip.md

Correct mode mismatches in RISC-V bit manipulation instructions.

This commit corrects mode mismatches in the RISC-V bitmanip.md file, addressing issues found by an LLM review. Two patterns incorrectly used narrower modes for operands when the operation required a wider mode. The fix involves using the full DI (Double Integer) mode for shift counts, ensuring correct masking of bits and resolving testsuite regressions.

In Details

This commit rectifies two incorrect mode definitions in RISC-V's config/riscv/bitmanip.md. The patterns *<bitmanip_optab>3_mask_si and *<bitmanip_optab>si3_sext_mask were using SI (Single Integer) mode for shift count operands, while the operation implicitly required DI (Double Integer) mode, especially when TARGET_64BIT is enabled. The fix changes these to use DI mode, effectively masking the necessary bits and preventing regressions observed in the testsuite, likely due to subreg matching an SI rather than the full DI value.

For Context
RISC-V
An open-source instruction set architecture (ISA) based on reduced instruction set computing principles. GCC supports various RISC-V configurations.
bitmanip.md
A machine description file in GCC that defines patterns for bit manipulation instructions for a specific architecture, in this case, RISC-V.
mode
In GCC, a 'mode' represents a data type or size that an operand can take, such as 'SI' for 32-bit integer or 'DI' for 64-bit integer.
DI mode
GCC's internal representation for a 64-bit integer operand.
SI mode
GCC's internal representation for a 32-bit integer operand.
subreg
A subregister, which is a portion of a larger register. GCC uses subregs to handle operations on smaller parts of wider registers.
Filed Under: risc-voptimizationcompiler