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]
Other format: [Raw text]

Re: Enable first scheduling pass for SH4


"Sanjiv Kumar Gupta, Noida" wrote:
> 
> > > > On Wed, Sep 03, 2003 at 01:56:26PM +0530, Sanjiv Kumar Gupta,
> > > > Noida wrote:
> > > > > The overall idea is to keep count of SImode and SFmode regs
> > > > required by
> > > > > already scheduled insns.
> > > >
> > > > I don't think this should at all be done via magic hooks in
> > > > the sh backend.
> > >
> > > The heuristics are pretty target specific. Do you think,
> > > I should change the generic scheduler for this?
> > >
> > I think Richard is right.  You could make it more general (register
> > pressure calculation and reordering ready queue) because it could be
> > profitable for other ports (like arm or sparc)  too.  Then the most of
> > code could be in the scheduler itself.  And may be one hook
> > to switch on (off) the heuristic for ports which could have benefit from
> this
> > heuristic.  If there is no harm from this for all ports, the
> > hook could be removed.
> 
> The attached patch makes register pressure calculation for SFmode/SImodes
> in generic scheduler. A new target hook is added to use the code. The
> hook lets a target define when insn movement needs to be throttled.
> It can see the how many SImode/SFModes regs are in use in current schedule
> and returns non-zero, in case, ready_queue is to be reordered based
> on register pressure.More modes might be added later if needed.
> In case of SH, r0 needs special consideration. This is accomodated
> in sh_track_register_pressure.
> 

  Sanjiv, I am sorry but the current patch is useless for other ports. 
I think that the patch (if it should be machine-independent one) has the
following disadvantages:

1. Register pressure calculation is based on modes.  It is wrong.  It
should be based on register classes.  Each pseudo-register has preferred
class (this is the class whose register allocation to the pseudo results
in the minimal cost insns) and possibly alternative class (class whose
resister allocation to the pseudo results in insns with cost less than
cost when memory is used for the pseudo).  

  Register allocator uses registers of these two classes for the
pseudo.  You could use one class for the pseudo (reg_class_subunion.  By
the way when somebody writes a port it is good practice to define
additional classes which are unions of other classes if a pseudo could
be allocated in the classes).  So when the pseudo starts live the
pressure for this one class should be increased.  Hard register should
increase pressure for each class it belongs to.  The register pressure
is high if the number of registers in a class is less than the class
register pressure.

2. The initial register pressure should be not zero but based on
global_live_at_start (although it is also inaccurate because a register
could live in gcc sense even if its value is not partially available).

3. The scheduler uses original order of insns when the register pressure
is too high.  It should try to decrease the pressure instead of the
original order usage.  An insn could increase pressure for one classes
and decrease it for other classes.  To choose the insn when the register
pressure is too high, you could use cost based on excessive register
pressure and costs of moving a register of the class to memory.

   And a minor comment.  When you use any heuristic value in
machine-independent code, please define it as parameter to be redefined
in --param.

  I realize that what I wrote is not easy to implement.  But that what
should it be if you are trying to implement in machine independent way. 
So if you decide not to implement this approach, I would prefer the
previous machine-depnendent approach.  Just let me know and I'll look at
the previous patch again and probably approve it.

Vlad


Vlad


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