GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc

Prevent equivalence substitution in LRA from causing incorrect reloads

LRA optimization pass now avoids a specific equivalence substitution that could lead to wrong memory reload offsets.

A bug in the GCC Link-Time Register Allocation (LRA) pass could cause incorrect memory addresses to be used for reloads when employing equivalence substitution. This occurred because the elimination offset was updated only once per instruction, leading to an incorrect offset in the output reload instruction. To fix this, equivalence substitution is now disabled in specific cases where it is not profitable and complex to fix, preventing the incorrect reloads.

In Details

The LRA pass in GCC has been modified to disable equivalence substitution in certain scenarios to avoid incorrect memory reload offsets. This issue arose from the interplay of memory-memory moves with stack pointer predecrements and address post-increments, where the register elimination offset update was not granular enough for equivalence optimizations. The change targets specific constraints within lra-constraints.cc to prevent this problematic optimization.

For Context
LRA
Link-Time Register Allocation is a compiler optimization pass that performs register allocation after link-time optimization. It aims to reduce memory spills by assigning frequently used variables to registers.
equivalence substitution
An optimization technique where one memory operand is replaced by another equivalent memory operand, often to simplify instruction scheduling or register allocation. In this context, it refers to replacing a memory access with another.
reload
In register allocation, a reload refers to an instruction that loads a value from memory into a register when the compiler determines that the register containing the value has been overwritten or is unavailable.
Filed Under: optimizationcompiler