public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: Mark Mitchell <mark@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org
Subject: Re: [PATCH][RFC] Adjust the middle-end memory model
Date: Wed, 20 May 2009 21:34:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.0905202010180.25789@zhemvz.fhfr.qr> (raw)
In-Reply-To: <4A14288E.4060304@codesourcery.com>

On Wed, 20 May 2009, Mark Mitchell wrote:

> Richard Guenther wrote:
> 
> >>   void f(float *f, int *n) {
> >>     for (int i = 0; i < *n; ++i) {
> >>       f[i] *= 2;
> >>     }
> >>   }
> 
> > The difference is if you want to sink a load from *n beyond the
> > store to f[i] - in which case you ask if there is an anti-dependence
> > which we cannot exclude in this case (no TBAA is allowed here).
> 
> By "not allowed", you don't mean "would be an invalid optimization", but
> rather "will no longer be done by GCC", right?

Right, not invalid in the above case but nevertheless no longer being
done by GCC.  This is to properly support

int i;
float f;
void foo()
{
  int *p = (int *)malloc(sizeof(int));
  *p = 1;
  i = *p;
  float *q = (float *)p;
  *q = 2.0;
  f = *q;
}

where we need to avoid scheduling the store via *q before the load
from *p.  The above is valid as I read C99 6.5/6, it is an object
with no declared type (obtained via malloc) and has type int
due to the store via *p "for that access and for subsequent accesses
_that do not modify the stored value_." (emphasis mine).  So for
objects without a declared type C can do "placement new" by simply
storing with a different type.  In C++ we of course have the
usual placement new situations.

Richard.

  reply	other threads:[~2009-05-20 18:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <alpine.LNX.2.00.0905081221560.25789@zhemvz.fhfr.qr>
2009-05-19 15:25 ` Richard Guenther
2009-05-19 19:10   ` Mark Mitchell
2009-05-20 14:13     ` Richard Guenther
2009-05-20 18:15       ` Mark Mitchell
2009-05-20 21:34         ` Richard Guenther [this message]
2009-05-21  5:11           ` Mark Mitchell
2009-05-22 15:17             ` Richard Guenther
2009-05-23  7:05               ` Mark Mitchell

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=alpine.LNX.2.00.0905202010180.25789@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=mark@codesourcery.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).