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

Fix multiple small RISC-V bugs discovered during LLM review

Addresses several RISC-V specific bugs related to shift behavior, synthesis, and operand handling.

This commit resolves multiple minor bugs in the RISC-V backend, identified with the aid of an LLM review. Issues fixed include undefined behavior from shifts by object size, an off-by-one error in rotate synthesis, incorrect instruction generation for AND operations under specific feature combinations, and a design flaw where output could be written before inputs were consumed in overflow and division/modulo expanders. These fixes improve code generation correctness and robustness for RISC-V targets.

In Details

This patch addresses several issues in the RISC-V machine description. For synthesize_xor, it avoids undefined shift behavior and corrects an off-by-one error in rotate synthesis. synthesize_and is fixed to prevent generating unrecognized instructions when ZBB is enabled but ZKBM is not. For various arithmetic expanders (addv, subv, divmod), make_safe_from is used to ensure inputs are consumed before outputs are written, resolving a design defect. Finally, a masked shift splitter is corrected to use HOST_WIDE_INT_1U to prevent shifts by large amounts.

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on reduced instruction set computing principles.
LLM
Large Language Model, an AI model used here to review code and identify potential bugs or areas for improvement.
ZBB, ZKBM
Extensions to the RISC-V ISA. ZBB provides bit manipulation instructions, and ZKBM provides bit matrix multiplication instructions.
HOST_WIDE_INT_1U
A C preprocessor macro that defines an unsigned integer type large enough to hold any value representable by the host's word size, used for intermediate calculations in the compiler.
make_safe_from
A function or macro used in GCC's machine description to ensure that output operands of an instruction are not written until all input operands have been safely read.
Filed Under: risc-vbugfix