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

Fix various length problems in RISC-V port

Corrects instruction length computations for several RISC-V patterns.

This commit addresses several inaccuracies in instruction length calculations within the RISC-V port of GCC. LLM reviews identified discrepancies in patterns related to the Zba extension, internal CFI calls, and stack protection sequences. The incorrect length computations, though not causing functional issues, have been fixed to accurately reflect the generated machine code size.

In Details

Several RISC-V specific RTL patterns have had their size computations corrected. The f<quiet_pattern>_quiet<ANYF:mode><X:mode>4_zfa pattern, related to the Zba extension, previously claimed a size of 16 bytes for a single instruction, which was incorrect. Similarly, call_internal_cfi and call_value_internal_cfi patterns, along with gpr_save, did not account for .p2align directives, leading to an underestimation of their size by 2 bytes. The stack_protect_test pattern also had its reported size adjusted from 12 to 16 bytes to match its 4-instruction sequence. These fixes ensure acc…

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on modularity, extensibility, and simplicity.
Zba
A RISC-V extension that adds bit manipulation instructions, including address generation and permutation operations.
CFI
Control Flow Integrity. A security mechanism designed to prevent control-flow hijacking attacks by ensuring that indirect branches only transfer control to valid targets.
.p2align
An assembler directive used to align the subsequent code or data to a specified power-of-two boundary, which can improve performance on some architectures.
RTL
Register Transfer Language, an intermediate representation used within GCC to describe code transformations and instruction generation.
Filed Under: risc-vcode generationperformance