public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <bonzini@gnu.org>
To: gcc@gcc.gnu.org, richard.sandiford@linaro.org
Subject: Re: Just what are rtx costs?
Date: Wed, 17 Aug 2011 18:56:00 -0000	[thread overview]
Message-ID: <4E4C0ECE.8060503@gnu.org> (raw)
In-Reply-To: <m3aab8rsya.fsf@richards-thinkpad.stglab.manchester.uk.ibm.com>

On 08/17/2011 07:52 AM, Richard Sandiford wrote:
>    cost = rtx_cost (SET_SRC (set), SET, speed);
>    return cost>  0 ? cost : COSTS_N_INSNS (1);
>
> This ignores SET_DEST (the problem I'm trying to fix).  It also means
> that constants that are slightly more expensive than a register --
> somewhere in the range [0, COSTS_N_INSNS (1)] -- end up seeming
> cheaper than registers.

This can be fixed by doing

   return cost >= COSTS_N_INSNS (1) ? cost : COSTS_N_INSNS (1);

> One approach I'm trying is to make sure that every target that doesn't
> explicitly handle SET does nothing with it.  (Targets that do handle
> SET remain unchanged.)  Then, if we see a SET whose SET_SRC is a
> register, constant, memory or subreg, we give it cost:
>
>      COSTS_N_INSNS (1)
>      + rtx_cost (SET_DEST (x), SET, speed)
>      + rtx_cost (SET_SRC (x), SET, speed)
>
> as now.  In other cases we give it a cost of:
>
>      rtx_cost (SET_DEST (x), SET, speed)
>      + rtx_cost (SET_SRC (x), SET, speed)
>
> But that hardly seems clean either.  Perhaps we should instead make
> the SET_SRC always include the cost of the SET, even for registers,
> constants and the like.  Thoughts?

Similarly, this becomes

   dest_cost = rtx_cost (SET_DEST (x), SET, speed);
   src_cost = MAX (rtx_cost (SET_SRC (x), SET, speed),
                   COSTS_N_INSNS (1));
   return dest_cost + src_cost;

How does this look?

Paolo

  parent reply	other threads:[~2011-08-17 18:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-17 14:52 Richard Sandiford
2011-08-17 17:29 ` Georg-Johann Lay
2011-08-19 12:25   ` Richard Sandiford
2011-08-21 17:03     ` Georg-Johann Lay
2011-08-22  8:20       ` Richard Sandiford
2011-08-22  9:59         ` Richard Guenther
2011-08-22 13:08           ` Joern Rennecke
2011-08-22 15:53             ` David Edelsohn
2011-08-22 12:12         ` Georg-Johann Lay
2011-08-22 23:23       ` Peter Bigot
2011-08-26 14:41         ` Georg-Johann Lay
2011-08-17 18:56 ` Paolo Bonzini [this message]
2011-08-18  7:58   ` Richard Sandiford
2011-08-18  0:55 ` Hans-Peter Nilsson
2011-08-18  8:14   ` Richard Sandiford
2011-08-19 14:17   ` Richard Sandiford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4C0ECE.8060503@gnu.org \
    --to=bonzini@gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=richard.sandiford@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).