On Wed, Jun 24, 2026 at 4:28 PM Jovan Dmitrovic
<[email protected]> wrote:
>
> In function ivopts_estimate_reg_pressure, return zero if there are
> enough registers available so that spilling is not necessary.

This is OK.  And OK to push independently of 2/3 or 3/3.

It might be contrary to how we deal with available
register costs in the other cases but there's no target cost for
registers when we have enough of them in target_cfgloop.
Assuming zero cost makes as much sense as one, costing
n_new instead of <whatever factor> * regs_needed doesn't,
so the proposed result is strictly better from a logical point.
It's the most extreme, so most likely to show up issues if
there are any.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure):
>         Return zero if there are enough registers to store new
>         invariants and induction variables.
>
> Suggested-by:  Richard Biener <[email protected]>
> Signed-off-by: Jovan Dmitrović <[email protected]>
> Signed-off-by: Djordje Todorović <[email protected]>
> Signed-off-by: Chao-Ying Fu <[email protected]>
> Signed-off-by: Radosav Krunić <[email protected]>
> ---
>  gcc/tree-ssa-loop-ivopts.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
> index bbd3cfaab243..00d5031893c1 100644
> --- a/gcc/tree-ssa-loop-ivopts.cc
> +++ b/gcc/tree-ssa-loop-ivopts.cc
> @@ -6092,7 +6092,7 @@ ivopts_estimate_reg_pressure (struct ivopts_data *data, 
> unsigned n_invs,
>
>    /* If we have enough registers.  */
>    if (regs_needed + target_res_regs < available_regs)
> -    cost = n_new;
> +    cost = 0;
>    /* If close to running out of registers, try to preserve them.  */
>    else if (regs_needed <= available_regs)
>      cost = target_reg_cost [speed] * regs_needed;
> --
> 2.34.1

Reply via email to