GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/lra

Inherit optional reload for output operands

Fixes incorrect code generation by ensuring optional reloads for output operands are properly inherited.

This commit corrects a bug in the late-stage register allocator (LRA) where optional reloads for output operands were not being inherited. This oversight resulted in suboptimal or incorrect code generation for certain operations. The patch introduces a new function, inheritance_pseudo_p, and modifies undo_optional_reloads to ensure that optional reloads for output operands are preserved if they are inherited, thereby fixing the reported issue and improving code quality.

In Details

Addresses PR rtl-optimization/127244 by fixing the inheritance of optional reloads for output operands in the LRA pass. The function undo_optional_reloads previously did not correctly handle cases where an output operand had an optional reload that should have been inherited. The new function inheritance_pseudo_p likely helps identify such pseudo-registers, ensuring that the optional reload is kept, thus preventing incorrect register assignments or spurious reloads that degrade code quality.

For Context
LRA
Late Register Allocator, a pass in GCC that performs register allocation after most optimizations have been completed.
optional reload
A reload operation that is not strictly necessary but can be performed to potentially improve code quality or satisfy certain constraints. It might be omitted under specific conditions.
output operand
In an instruction or operation, an operand that receives the result of the operation.
pseudo-register
A temporary register used by the compiler during intermediate stages, which may or may not be mapped to a physical register.
RTL
Register Transfer Level, an intermediate representation used in GCC after the high-level language is parsed and transformed.
Filed Under: register allocationoptimizationcompiler bug