Hi Richard, > don't you add n_invs twice now given > > unsigned n_old = data->regs_used, n_new = n_invs + n_cands; > unsigned regs_needed = n_new + n_old, available_regs = target_avail_regs; > > ?
If you are referring to the "If we have enough registers." case, correct. After c18101f, for that case, the returned cost is equal to 2 * n_invs + n_cands. Before c18101f, for that case, the returned cost is equal to n_invs + n_cands. Another solution would be to just return n_invs + n_cands if we have enough registers. Regards, Dimitrije From: Richard Biener <richard.guent...@gmail.com> Sent: Tuesday, October 25, 2022 1:07 PM To: Dimitrije Milosevic <dimitrije.milose...@syrmia.com> Cc: gcc-patches@gcc.gnu.org <gcc-patches@gcc.gnu.org>; Djordje Todorovic <djordje.todoro...@syrmia.com> Subject: Re: [PATCH 2/2] ivopts: Consider number of invariants when calculating register pressure. On Fri, Oct 21, 2022 at 3:57 PM Dimitrije Milosevic <dimitrije.milose...@syrmia.com> wrote: > > From: Dimitrije Milošević <dimitrije.milose...@syrmia.com> > > This patch slightly modifies register pressure model function to consider > both the number of invariants and the number of candidates, rather than > just the number of candidates. This used to be the case before c18101f. don't you add n_invs twice now given unsigned n_old = data->regs_used, n_new = n_invs + n_cands; unsigned regs_needed = n_new + n_old, available_regs = target_avail_regs; ? > gcc/ChangeLog: > > * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure): Adjust. > > Signed-off-by: Dimitrije Milosevic <dimitrije.milose...@syrmia.com> > --- > gcc/tree-ssa-loop-ivopts.cc | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc > index d53ba05a4f6..9d0b669d671 100644 > --- a/gcc/tree-ssa-loop-ivopts.cc > +++ b/gcc/tree-ssa-loop-ivopts.cc > @@ -6409,9 +6409,9 @@ ivopts_estimate_reg_pressure (struct ivopts_data *data, > unsigned n_invs, > + target_spill_cost [speed] * (n_cands - available_regs) * 2 > + target_spill_cost [speed] * (regs_needed - n_cands); > > - /* Finally, add the number of candidates, so that we prefer eliminating > - induction variables if possible. */ > - return cost + n_cands; > + /* Finally, add the number of invariants and the number of candidates, > + so that we prefer eliminating induction variables if possible. */ > + return cost + n_invs + n_cands; > } > > /* For each size of the induction variable set determine the penalty. */ > -- > 2.25.1 >