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

Fix miscellaneous bugs found by LLM review in RISC-V port

Corrects several bugs in the RISC-V backend identified by LLM analysis, improving correctness and portability.

This commit addresses several issues found in the RISC-V GCC port through an LLM review. It refines the zero-extension logic to ensure mode consistency, generalizes a bit manipulation instruction pattern to support both RV32 and RV64, and corrects the use of subregisters in conditional shift operations to prevent nested subregister issues. These fixes enhance the robustness and correctness of the RISC-V backend.

In Details

This patch cleans up the RISC-V backend based on LLM review findings. Specifically, it corrects a mode mismatch in zero_extendhi<GPR:mode>2 when optimizing promoted subregs, ensures the a >= 0 ? b : 0 splitter in bitmanip.md is RV32-compatible by using BITS_PER_WORD - 1, and replaces explicit subreg construction with subreg_lowpart in the zicond.md conditional shift splitter to avoid nested subregs. These changes improve code generation correctness and portability across RISC-V variants.

For Context
LLM
Large Language Model, an AI system used here to analyze code and identify potential bugs or areas for improvement.
zero extension
An operation that extends a smaller integer value to a larger one by filling the upper bits with zeros.
promoted subreg
A subregister that has been extended to a larger mode, common in intermediate code generation.
DI mode
A GCC internal mode representing a double-precision integer, typically 64 bits.
RV32
A 32-bit variant of the RISC-V instruction set architecture.
RV64
A 64-bit variant of the RISC-V instruction set architecture.
subreg
A part of a larger register, used when an operation only needs a portion of a register's value.
subreg_lowpart
A GCC intrinsic function that extracts the lower part of a subregister, ensuring correct mode handling.
Filed Under: risc-vbugfixcode generation