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

Fix RISC-V bit manipulation instruction patterns

Corrects several bugs in the RISC-V bit manipulation instruction patterns within GCC's machine description.

This commit addresses four issues found in GCC’s RISC-V bitmanip.md file, identified with the assistance of an LLM. Problems included an incorrect pattern for sext_hwi that failed to handle bits in the upper half of a 64-bit value, a clobber operand with a mismatched mode in a splitter, a pattern where an AND operation on two SI operands was incorrectly configured for a DI mode, and a missing TARGET_ZBS condition for a Zbs bit extraction pattern. These issues have been fixed by removing a problematic pattern, correcting operand modes, fixing mode mismatches, and adding the necessary target condition.

In Details

The RISC-V bitmanip.md file had several incorrect patterns. One pattern using sext_hwi for checking 32-to-64-bit extension was removed due to incorrect logic. A splitter's clobber operand mode was corrected from 'X' to GPR. An AND operation pattern was fixed to have consistent SI operands for its DI mode. Finally, a bit extraction pattern was made conditional on TARGET_ZBS for correctness. These changes resolve potential incorrect code generation or ICEs related to bit manipulation instructions.

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computer principles.
bitmanip.md
A machine description file used by GCC for the RISC-V architecture, specifying patterns for bit manipulation instructions.
sext_hwi
An RTX (RTL expression) pattern representing sign-extension of a hardware integer, used in GCC's intermediate representation.
GPR
General-Purpose Register. A register in a CPU that can be used for various data manipulation purposes.
SI
Single Integer, typically a 32-bit integer type in GCC.
DI
Double Integer, typically a 64-bit integer type in GCC.
Zbs
A RISC-V extension that provides bit string manipulation instructions, including bit extraction.
LLM
Large Language Model, an AI system used here to review and identify potential bugs in the machine description file.
Filed Under: risc-voptimizationbugfixrtl