This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: A question about using restrict


Hello Bingfeng,

Thanks for your reply! I would be very interested to try your patch.

Revital




From:	"Bingfeng Mei" <bmei@broadcom.com>
To:	Revital1 Eres/Haifa/IBM@IBMIL, "gcc@gcc.gnu.org"
            <gcc@gcc.gnu.org>
Date:	13/12/2010 12:20 PM
Subject:	RE: A question about using restrict



Hi, Revital,
Sorry for late reply. I think you can write following code
according to C99 standard to make sure src1/src2 don't alias
with dst. However, current GCC support for restrict is still
quite weak. The restrict info tends to be lost in all optimizations,
especially ivopts. You won't get the intended result. I have some
internal patch for 4.5 to track the source of a pointer.
It is not a very efficient implementation but works for us so far.
I can send to you if you are interested.

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

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

Cheers,
Bingfeng

> -----Original Message-----
> From: Revital1 Eres [mailto:ERES@il.ibm.com]
> Sent: 13 December 2010 07:59
> To: gcc@gcc.gnu.org
> Cc: Bingfeng Mei
> Subject: A question about using restrict
>
>
> 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]);
>       }
> }
>
>





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]