public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Richard Sandiford <richard.sandiford@linaro.org>
Cc: gcc@gcc.gnu.org
Subject: Re: Help with ivopts
Date: Wed, 06 Jul 2011 14:40:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1107061558230.17483@wotan.suse.de> (raw)
In-Reply-To: <g4tyazikxx.fsf@linaro.org>

Hi,

On Wed, 6 Jul 2011, Richard Sandiford wrote:

> > If the target allows (q-p)[n] to be used directly as an address, and 
> > if the target has no post-increment instruction, then it might be 
> > better. But I think it's a loss on other targets.  It might even be a 
> > loss on targets (like PowerPC IIRC), that need base+index addresses to 
> > have the "real" base first.  This sort of transformation seems to make 
> > us lose track of which register is the base.
> 
> Actually, I take that back.  Use of (p-q)[n] (hoisted_diff[n]) as an 
> address is precisely the case in which we've decided we _don't_ want to 
> apply the optimisation (see the address_p code I quoted).

I know, I was referring to the general case of uses of IVs, not 
necessarily in address context, it was just easier to write.  The reason 
for disabling this in address context is not because of having no 
advantage, but rather because accessing objects without a useful base (and 
"&obj1 - &obj2" is no useful one) in the past lead to wrong aliasing 
answers.  Meanwhile it shouldn't lead to wrong answers anymore, but still 
to less precise ones.

I wrote the example only to show the situation in which such seemingly 
strange transformation (building the difference of unrelated entities) is 
actually helpful.

> So I'm not sure when it's a win even on targets like x86.

In my example (and imaging that p[i] actually stands for some arbitrary 
arithmetic involving the sum of p and i, or if we would remove the 
address_p special case) the transformation is universally a win.  In your 
example it isn't a win because the address operations are as simple as 
possible to start with, and become more complex due to the transformation, 
that would point towards a glitch in the cost analysis. It's still getting 
rid of one induction variable, but I'd agree that that's no advantage with 
post-increment targets, and even without postinc the increased complexity 
of the address makes the transformation dubious.  A better transformation 
would be to get rid of the i induction variable.


Ciao,
Michael.

  reply	other threads:[~2011-07-06 14:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06 11:35 Richard Sandiford
2011-07-06 13:10 ` Michael Matz
2011-07-06 13:32   ` Richard Sandiford
2011-07-06 13:43     ` Richard Sandiford
2011-07-06 14:40       ` Michael Matz [this message]
2011-07-06 15:04         ` Richard Sandiford
2011-07-06 15:17           ` Michael Matz
2011-07-06 15:34             ` Richard Sandiford
2011-07-06 15:56               ` Michael Matz
2011-07-06 17:55                 ` 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.1107061558230.17483@wotan.suse.de \
    --to=matz@suse.de \
    --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).