On Wed, Jun 24, 2026 at 4:28 PM Jovan Dmitrovic
<[email protected]> wrote:
>
> Function ivopts_estimate_reg_pressure is taxing candidate sets
> by the number of candidates included in set. This makes for an
> uneven playing field, making it very difficult for larger sets
> to be chosen.
>
> In try_improve_iv_set to candidate set another candidate is added
> only if the cost improves (therefore prefering fewer candidates
> per set), but having reg pressure cost factor in the number of
> candidates makes a disbalance when choosing the best option.

This is OK (as it's simpler than 2/3 it should be re-ordered), it
can be pushed independently.

Richard.

> gcc/ChangeLog:
>
>         * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure):
>         Remove n_cands bias from reg pressure cost calculation.
>
> Co-authored-by: Radosav Krunić <[email protected]>
> Signed-off-by: Djordje Todorović <[email protected]>
> Signed-off-by: Chao-Ying Fu <[email protected]>
> Signed-off-by: Jovan Dmitrović <[email protected]>
> Signed-off-by: Radosav Krunić <[email protected]>
> ---
>  gcc/tree-ssa-loop-ivopts.cc | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
> index 95c6dcf767ab..ef9274c4d6fb 100644
> --- a/gcc/tree-ssa-loop-ivopts.cc
> +++ b/gcc/tree-ssa-loop-ivopts.cc
> @@ -6113,10 +6113,8 @@ ivopts_estimate_reg_pressure (struct ivopts_data 
> *data, unsigned n_invs,
>      }
>
>    /* Adjust cost of invariant register pressure in order to make
> -     the spilling of induction variables the most taxing.
> -     Finally, add the number of candidates, so that we prefer eliminating
> -     induction variables if possible.  */
> -  return adjust_setup_cost(data, cost) + iv_spill_cost + n_cands;
> +     the spilling of induction variables the most taxing. */
> +  return adjust_setup_cost(data, cost) + iv_spill_cost;
>  }
>
>  /* For each size of the induction variable set determine the penalty.  */
> --
> 2.34.1

Reply via email to