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

ivopts: Remove bias from register pressure cost calculation.

Loop invariant optimization pass removes a bias in register pressure cost that unfairly penalized larger candidate sets.

The ivopts_estimate_reg_pressure function was previously biased by the number of candidates in a set, making larger sets less likely to be chosen. This change removes that bias, allowing the optimizer to more fairly evaluate sets with varying numbers of loop-invariant candidates, improving the selection of optimal candidate sets.

In Details

This commit modifies the ivopts_estimate_reg_pressure function within GCC's loop optimization passes. It removes a multiplicative factor that scaled the register pressure cost by the number of candidates (n_cands). This bias previously discouraged the selection of larger, potentially more beneficial, sets of loop invariants. The change ensures that the evaluation of candidate sets is fairer and based more directly on actual register pressure rather than an artifact of set size.

For Context
ivopts
A GCC optimization pass that identifies and hoists loop-invariant computations out of loops to reduce redundant calculations.
register pressure
A metric used by compilers to estimate how many registers are needed at a given point in the code. High register pressure can lead to spills (storing register values to memory), impacting performance.
loop-invariant
An expression or value within a loop whose value does not change from one iteration to the next.
candidate set
In the context of ivopts, a collection of loop-invariant expressions being considered for hoisting out of a loop.
Filed Under: optimizationcompiler