public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: "Bingfeng Mei" <bmei@broadcom.com>
Cc: "Richard Guenther" <richard.guenther@gmail.com>,
	       "gcc\@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: Re: Is this correct behaviour?
Date: Tue, 06 Sep 2011 22:30:00 -0000	[thread overview]
Message-ID: <mcrk49ltibr.fsf@coign.corp.google.com> (raw)
In-Reply-To: <7FB04A5C213E9943A72EE127DB74F0ADD15FB6A5E3@SJEXCHCCR02.corp.ad.broadcom.com>	(Bingfeng Mei's message of "Tue, 6 Sep 2011 08:53:51 -0700")

"Bingfeng Mei" <bmei@broadcom.com> writes:

> Then how do I tell compiler that "a" is not aliased if I have to use global variable? 
>
>> 
>> > Thanks,
>> > Bingfeng Mei
>> >
>> > int a;
>> > int P[100];
>> > void foo (int * restrict p)
>> > {
>> >  P[0] = *p;
>> >  a++;
>> >  P[1] = *p;
>> >  a++;
>> >  P[2] = *p;
>> >  a++;
>> > }

How about

int a;
int P[100];
void foo (int * restrict p)
{
  foo1 (p, P, &a);
}
void foo1 (int * restrict p, int * restrict pp, int * restrict pa)
{
  pp[0] = *p;
  a++;
  pp[1] = *p;
  a++;
  pp[2] = *p;
  a++;
}

Ian

      reply	other threads:[~2011-09-06 22:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06 15:31 Bingfeng Mei
2011-09-06 15:42 ` Richard Guenther
2011-09-06 15:54   ` Bingfeng Mei
2011-09-06 22:30     ` Ian Lance Taylor [this message]

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=mcrk49ltibr.fsf@coign.corp.google.com \
    --to=iant@google.com \
    --cc=bmei@broadcom.com \
    --cc=gcc@gcc.gnu.org \
    --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).