This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Problems with the way we calculate costs


  In message <Pine.LNX.4.21.0009111659510.6299-100000@mahatma.cygnus.co.uk>you 
write:
  > On Mon, 11 Sep 2000, Geoff Keating wrote:
  > 
  > > > Date: Mon, 11 Sep 2000 10:15:25 +0100 (BST)
  > > > From: Bernd Schmidt <bernds@redhat.co.uk>
  > > > cc: gcc-patches@gcc.gnu.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).
  > 
  > Bernd
  > 
  > 	* 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
  > 	MAX_COST.
  > 	(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
  > 	constant.
This is fine.  Please install this patch.

Thanks,
jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]