GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ira

ira: Add TARGET_IRA_LOOP_REGION_FLATTEN_COST

New compiler hook allows targets to preserve low-pressure loop regions during register allocation.

GCC’s Instruction Register Allocation (IRA) pass now includes a new target hook, TARGET_IRA_LOOP_REGION_FLATTEN_COST. This hook allows target architectures to define whether a low-pressure loop should be kept as a separate IRA region instead of being flattened into its parent. The decision is based on factors like the frequency of calls within the loop and the number of pseudos live across calls, compared to the loop’s entry and exit edge frequencies. The hook is called before flattening, and if it returns a positive value, the loop region is preserved.

In Details

This commit introduces the ira_loop_region_flatten_cost hook to GCC's IRA pass. This hook provides a mechanism for targets to influence the decision of whether to flatten a loop region into its parent region. The hook is invoked when a loop is identified as 'low-pressure' (fewer pseudos live across calls than callee-saved registers) and its subloops have already been processed. It receives information about call frequencies within the loop and the number of edges, allowing it to calculate a cost. A positive return value signals IRA to keep the loop as a distinct region, preventing it from b…

For Context
IRA
Instruction Register Allocation, a phase in the compiler that assigns physical registers to virtual registers (pseudos).
hook
A point in a software system where custom code can be inserted or called, allowing for extensibility and customization by target-specific implementations.
loop region
A contiguous block of code within a loop that is treated as a single unit for certain optimization or analysis passes.
pseudos
Virtual registers used internally by the compiler during intermediate code generation and optimization before they are mapped to physical machine registers.
callee-saved registers
Registers that a called function must preserve the values of, meaning they must be saved by the callee before use and restored before returning, if their original values are needed by the caller.
Filed Under: iraregister allocationoptimizationtarget hook