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: restrict and char pointers


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 such.  I didn't think you were asking that question.  I
probably can't answer that question very well.

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 none.

Just above the section of code I pointed at earlier is this comment
which explains how we handle restrict in the gcc RTL aliasing code:
          /* No two restricted pointers can point at the same thing.
             However, a restricted pointer can point at the same thing
             as an unrestricted pointer, if that unrestricted pointer
             is based on the restricted pointer.  So, we make the
             alias set for the restricted pointer a subset of the
             alias set for the type pointed to by the type of the
             decl.  */
Perhaps more advanced alias analysis code can do better, but this is
what we do for now in the RTL aliasing code, and it is known to be safe.

There is also tree aliasing code, which is more advanced than the RTL
aliasing code, but I don't think it has any support for restrict yet. 
So effectively we are ignoring restrict there, which is allowed by the
standard.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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