public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Revital1 Eres <ERES@il.ibm.com>
To: gcc@gcc.gnu.org
Cc: bmei@broadcom.com
Subject: A question about using restrict
Date: Mon, 13 Dec 2010 07:58:00 -0000	[thread overview]
Message-ID: <OFD6414D0A.284548A3-ONC22577F7.003F2341-C22577F8.002BD2D0@il.ibm.com> (raw)


Hello,

I have the loop below and I want to pass to gcc that src1 and src2 never
alias with dst; so I used the restrict keyword as below; however I still
see that there are dependence edges between dst and src1 and src2 in
the DDG created by SMS and I wonder how can I resolve this.
(I used GCC -v167637 and compiled for powerpc)

Thanks,
Revital

Original version:

void foo(unsigned char  ***dst,
    unsigned char *src1,
    unsigned char  *src2, int row)
{
    int x;

    for( x = 0; x < 100; x+=1)
      {
        dst[0][row][x] = ( src1[x] * src2[x]);
      }
}

version 1 with restrict:

void foo(unsigned char  ***__restrict__ dst,
    unsigned char *__restrict__ src1,
    unsigned char  *__restrict__ src2, int row)
{
    int x;

    for( x = 0; x < 100; x+=1)
      {
        dst[0][row][x] = ( src1[x] * src2[x]);
      }
}

version 2 with restrict:

void
foo(unsigned char  *** __restrict__ dst,
    unsigned char * __restrict__ src1,
    unsigned char  * __restrict__ src2, int row)
{
    int x;
    unsigned char  **__restrict__ dst1 = dst[0];
    unsigned char  * __restrict__ dst2 = dst1[row];

    for( x = 0; x < 100; x+=1)
      {
        dst2[x] = (src1[x] * src2[x]);
      }
}


             reply	other threads:[~2010-12-13  7:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-13  7:58 Revital1 Eres [this message]
2010-12-13 10:20 ` Bingfeng Mei
2010-12-13 10:37   ` Revital1 Eres
2010-12-13 15:59     ` Bingfeng Mei

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=OFD6414D0A.284548A3-ONC22577F7.003F2341-C22577F8.002BD2D0@il.ibm.com \
    --to=eres@il.ibm.com \
    --cc=bmei@broadcom.com \
    --cc=gcc@gcc.gnu.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).