public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Richard Sandiford <rdsandiford@googlemail.com>
Cc: Paolo Bonzini <bonzini@gnu.org>,
		Richard Guenther <richard.guenther@gmail.com>,
		gcc-patches@gcc.gnu.org
Subject: Re: RFC patch: invariant addresses too cheap
Date: Tue, 01 Dec 2009 13:05:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0912011254270.18785@wotan.suse.de> (raw)
In-Reply-To: <87einjaski.fsf@firetop.home>

Hi,

On Sat, 28 Nov 2009, Richard Sandiford wrote:

> > Hmm.  Looking at the example in that PR, am I right in thinking that 
> > the x86 backend says that the (%rdi,%rax,4) and 16(%rsp,%rax,4) 
> > addresses have the same cost?  It looks that way from the code, and 
> > fwprop wouldn't have made the substitution otherwise, right?
> >
> > If so, why do they have equal cost, given that replacing one address 
> > with the other led to such a drastic performance drop?
> >
> > (I know I'm missing something here, sorry.)
> 
> But without understanding the answer to the question in my earlier mail,
> it still seems to me that this whole idea of checking for cheap
> addresses in loop-invariant.c is tackling things in the wrong way.

The answer to your questions are: yes, you're right.  It is so to generate 
better code, because as the comment in front of ix86_address_cost says, 
it's better on x86 to generate more complex addresses than to load them 
into registers, hence a constant offset isn't taken into account, neither 
is a scaling.  (To say the truth, on some micro architectures addresses 
that use all components are tougher to the decoder).  In the past we even 
made more complex addresses _cheaper_ than simple one (!), which is, well 
..., wrong ;-) but once generated better code.

Unfortunately these target knobs are more an art than a science, and 
defining them in a logical way derivable from hardware manuals often leads 
to suboptimal code :-/

Having said that, I'm not sure why the answer to this question matters 
to you: neither the PR33928 testcase, nor 410.bwaves was about (reg,reg,4) 
vs. ofs(reg,reg,4).  The former was about ofs(reg) vs ofs2(reg) and the 
latter was about (reg) vs (reg,reg).

FWIW I'd also say that fwprop2 would be a good place to sink invariants 
generally (so that loop-invariant could hoist them as it wants).  But I 
don't see how that will get rid of having to compute an absolute cheapness 
(as fwprop2 would only want to sink the invariantes into cheap places).


Ciao,
Michael.

  reply	other threads:[~2009-12-01 12:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-19 16:17 Michael Matz
2009-10-19 16:45 ` Paolo Bonzini
2009-10-20  9:04   ` Richard Guenther
2009-10-20 12:07     ` Paolo Bonzini
2009-10-20 16:00       ` Michael Matz
2009-10-20 16:06         ` Richard Guenther
2009-10-31 10:05       ` Richard Sandiford
2009-10-31 11:14         ` Paolo Bonzini
2009-10-31 11:16           ` Richard Guenther
2009-10-31 12:56             ` Paolo Bonzini
2009-10-31 13:53               ` Richard Sandiford
2009-10-31 14:31                 ` Paolo Bonzini
2009-11-01 10:24                   ` Richard Sandiford
2009-11-01 10:25                     ` Paolo Bonzini
2009-11-14 11:19                     ` Richard Sandiford
2009-11-15 16:50                       ` Paolo Bonzini
2009-11-15 21:36                         ` Richard Sandiford
2009-11-28 10:53                           ` Richard Sandiford
2009-12-01 13:05                             ` Michael Matz [this message]
2009-12-02 22:24                               ` Richard Sandiford
2009-12-03 12:57                                 ` Michael Matz
2009-11-17 18:02                 ` Mark Mitchell
2009-10-31 19:23         ` Michael Matz
2009-11-01 10:13           ` 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=Pine.LNX.4.64.0912011254270.18785@wotan.suse.de \
    --to=matz@suse.de \
    --cc=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rdsandiford@googlemail.com \
    --cc=richard.guenther@gmail.com \
    /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).