Re: restrict and char pointers

2005-05-06 Thread Michael Matz
Hi, On Thu, 5 May 2005, Daniel Berlin wrote: > You can do it, but apparently restrict isn't as simple as "a and b are > both restrict pointers and therefore can never alias", because that's > not the actual definition of restrict. It says stuff about pointers > "based on" restricted objects, etc.

Re: restrict and char pointers

2005-05-05 Thread Daniel Berlin
On Wed, 2005-05-04 at 20:41 -0400, Diego Novillo wrote: > On Wed, May 04, 2005 at 05:08:23PM -0700, James E Wilson wrote: > > > We can perhaps handle this well in the tree-aliasing code (if > > it handled restrict at all), but it would be difficult to > > handle this well in the RTL aliasing code.

Re: restrict and char pointers

2005-05-04 Thread Diego Novillo
On Wed, May 04, 2005 at 05:08:23PM -0700, James E Wilson wrote: > We can perhaps handle this well in the tree-aliasing code (if > it handled restrict at all), but it would be difficult to > handle this well in the RTL aliasing code. > It doesn't. Mostly for similar reasons. Perhaps we could be m

Re: restrict and char pointers

2005-05-04 Thread James E Wilson
On Wed, 2005-05-04 at 16:24, Jeroen Dobbelaere wrote: > I'm aware of that. The reason are asked for more clarity is that I > think gcc should > do better (as in the example I gave), but I want to be sure that this > is still allowed > by the standard. Certainly gcc can and should do better, and th

Re: restrict and char pointers

2005-05-04 Thread Jeroen Dobbelaere
On 5/4/05, James E Wilson wrote: [..] > The standard says "A translator is free to ignore any or all aliasing > implications of restrict". So there is no conflict with the standard > here. We are free to do as little optimization as we want, and in the > case of a restricted char pointer, we do n

Re: restrict and char pointers

2005-05-04 Thread James E Wilson
On Wed, 2005-05-04 at 14:27, Jeroen Dobbelaere wrote: > Is this correct ? I was only trying to explain how gcc works for the one example that you posted. I was not trying to explain precise semantics of how restrict works according to the ISO C standard, and my message should not be construed as

Re: restrict and char pointers

2005-05-04 Thread Jeroen Dobbelaere
On 5/4/05, James E Wilson <[EMAIL PROTECTED]> wrote: [..] > The optimization does not happen for this example because we apparently > have no way to represent an alias set for a restricted char pointer. > char * and void * are allowed to alias anything. That is alias set 0 > internally. A restric

Re: restrict and char pointers

2005-05-04 Thread James E Wilson
Jeroen Dobbelaere wrote: void test_2(unsigned long* __restrict__ bar, char* __restrict__ bas) { unsigned long tmp = *bar; *bas = 0; *bar = tmp; } The optimization in the first example happens in the postreload cse pass, and is relying on RTL alias analysis info. The optimization does not ha

restrict and char pointers

2005-05-04 Thread Jeroen Dobbelaere
Hi, I have a question concerning '__restrict__' : With gcc-4.0.0 (-O3 -fomit-frame-pointer, on i686), following piece of code : void test_1(unsigned long* __restrict__ bar, unsigned long* __restrict__ bas) { unsigned long tmp = *bar; *bas = 0; *bar = tmp; } void test_2(unsigned long* __r