GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
rtl-optimization Performance Win

lra: Canonicalize whole-address reloads

Ensures correct instruction selection for addresses involving multiplications in the AArch64 reloader.

GCC’s instruction reloader (LRA) on AArch64 had issues recognizing addresses that involved a multiplication by a power of two, especially when this multiplication was part of a larger address calculation. The reloader would incorrectly generate a SET instruction for this part of the address, which didn’t match any available instruction, causing LRA to fail. This commit introduces a call to canonicalize_reload_addr to convert such multiplications into a canonical left-shift form (AShIFT), which LRA can then correctly recognize and emit the appropriate instruction. This fixes PR127056.

In Details

In the AArch64 backend's instruction reloader (LRA), addresses containing a multiplication by a power of two, when combined with other address components (e.g., a base register offset), could be problematic. The reload_inner_addr path would pass such an address directly to lra_emit_move, resulting in an RTL expression like (mult:DI (subreg:DI ...) (const_int 8)). This form, outside of specific address contexts like prefetch, is not directly instruction-generated. LRA's lra_set_insn_recog_data would fail because the generated SET did not match any instruction. This commit resolves th…

For Context
LRA
Local Register Allocation. A compiler phase that assigns physical machine registers to virtual registers used in the intermediate representation of the code, aiming to minimize memory spills.
reload
In register allocation, a 'reload' operation is inserted when a value needed by an instruction is not currently in a register and must be loaded from memory.
canonicalize
To transform an expression or value into a standard or preferred form. In this context, it means converting a multiplication by a power of two into an equivalent bit-shift operation for better instruction recognition.
RTL
Register Transfer Language. GCC's primary intermediate representation, which describes operations on registers and memory.
AShIFT
Arithmetic Shift Left. An RTL construct representing a bitwise left shift operation, often used as a canonical form for multiplication by powers of two.
Filed Under: rtl-optimizationaarch64lra