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

LRA: Propagate invariants for inherited pseudos to improve performance

LRA pass now propagates invariant information for inherited pseudos, preventing excessive register reloading and improving compilation speed.

The Local Register Allocation (LRA) pass has been enhanced to propagate invariant information for inherited pseudos. Previously, the elimination of invariants led to offsets falling out of immediate range, causing instructions to be reloaded. This reloaded state could trigger further invariant inheritance, creating a slow feedback loop. The fix records equivalence for inheritance pseudos, avoiding unnecessary spilling and the associated frame size changes that invalidated subsequent optimizations. This significantly speeds up compilation for code with many invariant occurrences.

In Details

This commit addresses a performance issue in the LRA pass related to invariant inheritance. When invariants (e.g., sfp + constant) are processed, they can create 'inheritance pseudos'. If these pseudos need to be spilled due to register pressure (especially on architectures like Thumb-1 with few hard registers), it increases the stack frame size. This change in frame size can invalidate offsets used by other instructions, leading to reloads and further invariant inheritance, causing LRA to iterate excessively. The fix introduces add_invariant to record equivalence for these inheritance pseu…

For Context
LRA
Local Register Allocator. A compiler pass responsible for assigning hard registers to virtual registers within a local code region. It runs after global register allocation and performs final register assignments.
Invariant
A value or expression whose result does not change during a particular loop or code section. Optimizations often try to compute invariants once and reuse the result.
Pseudos
Pseudoregisters. Virtual registers used by the compiler during intermediate representations. They are later mapped to physical hardware registers.
Inheritance Pseudos
Pseudoregisters created when an invariant value is used in a context that requires a register, and this invariant value is 'inherited' by the pseudoregister.
Spilling
The process of storing the value of a pseudoregister into a memory location (on the stack) because there are not enough available hardware registers to hold all the live values.
Immediate Range
The range of values that can be directly encoded into an instruction as an immediate operand. If a calculated offset exceeds this range, it must be loaded into a register first.
Filed Under: optimizationregister allocationperformance