This is the mail archive of the gcc-patches@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: [patch] handle restrict at tree level


On Thu, 1 Jul 2004, Dan Nicolaescu wrote:

> 2004-07-01  Dan Nicolaescu  <dann@ics.uci.edu>
>         PR14187
> 	* tree-ssa-alias.c (add_pointed_to_expr): Handle restricted
>           pointers the same way as malloc results.

(a) Is the GENERIC definition of restrict defined to be exactly that in
C99?  (I do hope that C++ doesn't add the feature but with a subtlely
different definition....)

(b) Malloc results do have the property of not aliasing anything not
derived from that malloc result, at all, for as long as it is valid.  
Restricted pointers (in C99) only have a non-aliasing property for
lifetime of the particular restricted pointer object, so you need to be
sure that the nonaliasing information doesn't escape that block when you
copy the restricted pointer to an outside nonrestricted pointer (copies to
outside restricted pointers have some restrictions).

(c) Another way in which the nonaliasing property of malloc results is
more general than that of restricted pointers is that the following
example (thanks to Nick Maclaren) appears to be well-defined; individual
accesses don't conflict, but you certainly can't conclude anything much
else about how the pointers A and B are related.  This may not be a
problem, but just illustrates that any optimization involving restrict
needs careful comparison with the standard text.

    void scatter (double * restrict A, double * restrict B) {
        int i;
        for (i = 0; i < 100; i += 2) A[i] = B[i] = 0.0;
    }

    int main (void) {
        static double array[200];
        scatter(array,&array[1]);
        return 0;
    }

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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