GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

LRA: Fix mode of subreg of const in constant pool.

This patch corrects the mode used for subregisters of constants placed in the constant pool by the LRA.

When the LRA (Local Register Allocator) places a constant value, which is part of a subregister, into the constant pool, it was using the wrong mode for the subregister within the pool memory. This patch corrects the mode to match the original subregister, which fixes a potential issue with incorrect data access. This ensures that subregister values are accessed correctly when loaded from constant pool.

In Details

The lra-constraints.cc file is responsible for LRA's handling of constraints during register allocation. The function curr_insn_transform recreates subregisters of constant values when placing them in the constant pool. This patch ensures that the subregister's mode is correctly preserved during this recreation. Incorrect mode assignment can lead to misinterpretation of the constant's value, impacting code correctness. Interacts with the RTL representation of data and LRA's memory management.

For Context

The constant pool is a region of memory where the compiler stores constant values used in the program. A 'subregister' is a portion of a larger register. The LRA is responsible for deciding where values live (registers or memory). This patch fixes an instance where the LRA was incorrectly tracking the type (or 'mode') of a subregister when storing a constant in memory, which could have led to incorrect code generation.

Filed Under: lraconstant poolbugfix