This is the mail archive of the
mailing list for the GCC project.
Re: Problems with the way we calculate costs
- To: Bernd Schmidt <bernds at redhat dot co dot uk>
- Subject: Re: Problems with the way we calculate costs
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 11 Sep 2000 10:51:42 -0600
- cc: Geoff Keating <geoffk at cygnus dot com>, gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <Pine.LNX.firstname.lastname@example.org>you
> On Mon, 11 Sep 2000, Geoff Keating wrote:
> > > Date: Mon, 11 Sep 2000 10:15:25 +0100 (BST)
> > > From: Bernd Schmidt <email@example.com>
> > > cc: firstname.lastname@example.org
> > >
> > > On Mon, 11 Sep 2000, Geoff Keating wrote:
> > >
> > > > It'd probably be better if it worked like the original code; that is,
> > > > the cost of a non-fixed hard register is 2, compared to 1 for a
> > > > pseudo. This ensures a pseudo gets preference, which would be the
> > > > usual case because such hard registers should be copied into pseudos
> > > > immediately after they appear.
> > >
> > > The original code mixed up these register pressure considerations with
> > > the calculation of the cost of an operation. I still think this is a
> > > bad idea. It also won't reliably prevent lifetimes of hard registers
> > > from being lenghtened (think of computing the cost of a shift of a
> > > hardreg as opposed to multiplication of a pseudo).
> > I don't mind hard register lifetimes being lengthened if it really
> > makes the program faster; what I was complaining about is when a
> > hardreg and a pseudo are equivalent and the hardreg gets preference.
> Hmm. OK. How about the patch below? I incorporated a few suggestions
> from other people as well (moved COSTS_N_INSNS into rtl.h and added a new
> macro MAX_COST). I've also changed COSTS_N_INSNS to (4 * N) to restore
> some of the old cost relationships we use to have in the compiler.
> > Probably the macro to consider is SMALL_REGISTER_CLASSES.
> With the patch, we'll either consider hard regs having a cost of 2 (for
> non-SRC machines), or forcing a return value of MAX_COST (for SRC).
> * cse.c (approx_reg_cost): If SMALL_REGISTER_CLASSES, return INT_MAX
> if a reference to non-fixed hardreg is seen. Otherwise, count hard
> regs with a higher cost.
> (preferrable): Deal with cases where either cost or regcost is
> (cse_insn): Use MAX_COST rather than 10000. Always initialize
> regcost values.
> (COSTS_N_INSNS): Move definition...
> * rtl.h: ...here.
> (MAX_COST): New macro.
> * loop.c (init_loop): Use COSTS_N_INSNS macro instead of hardcoded
This is fine. Please install this patch.