On Wed, May 23, 2018 at 08:33:13PM -0400, Paul Koning wrote:
> > On May 23, 2018, at 5:46 AM, Richard Biener <richard.guent...@gmail.com> 
> > wrote:
> >> 2. The reported costs for the various insns are
> >>         r22:HI=['x']            6
> >>         cmp(r22:HI,r23:HI)      4
> >>         cmp(['x'],['y'])        16
> >>    so the added cost for the memory argument in the cmp is 6 -- the same
> >> as the whole cost for the mov.  That certainly explains the behavior.  It
> >> isn't what I want it to be.  Which target hook(s) are involved in these
> >> numbers?  I don't see them in my rtx_costs hook.
> > 
> > The rtx_cost hook.   I think the costs above make sense.  There's also a
> > new insn_cost hook but you have to dig whether combine uses that.
> > Otherwise address_cost might be involved.
> 
> Thanks.  For a pdp11, those costs aren't right because mov and cmp and 
> a memory reference each have about the same cost.  So 8, 4, 12 would be 
> closer.  But the real question for me at this point is where to find
> the knobs that adjust these choices.
> 
> The various cost hooks have me confused, and the GCCINT manual is not
> really enlightening.  There is rtx_costs, insn_cost, and addr_cost.
> It sort of feels like insn_cost and addr_cost together would provide 
> roughly the same information that rtx_costs gives.  In the existing 
> platforms, I see rtx_costs everywhere, addr_cost in a fair number of
> targets, and insn_cost in just one (rs6000).  Can someone explain the
> interaction of these various cost hooks, and what happens if you define
> various combinations of the three?

rtx_costs computes the cost for any rtx (an insn, a set, a set source,
any random piece of one).  set_src_cost, set_rtx_cost, etc. are helper
functions that use that.

Those functions do not work for parallels.  Also, costs are not additive
like this simplified model assumes.  Also, more complex backends tend
to miss many cases in their rtx_costs function.

Many passes that want costs want to know the cost of a full insn.  Like
combine.  That's why I created insn_cost: it solves all of the above
problems.

I'll hopefully make most passes use insn_cost for GCC 9.  All of the very
easy ones already do.


Segher

Reply via email to