https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120972
--- Comment #6 from Feng Xue <fxue at os dot amperecomputing.com> --- (In reply to rguent...@suse.de from comment #5) > I see. I see annotating loops with pragmas as a more user-friendly way > of getting there. What we have at our disposal in terms of pragmas > is quite limiting though, and if the application is a benchmark where > changes are not allowed this doesn't help, of course. > > Handling outermost scope variables is reasonable I think. I'll note > another problem though, which is > > void foo (int *a, int *b) > { > int * __restrict p = a; > *p = *b; > p = b; > *p = *a; > } > > I'd have to re-read the standard wording but since on GIMPLE we can't > restrict ourselves to variables with initializer (that distinction > is lost), we have to deal with possibly multiple assignments to > the restrict qualified pointer (and the "first" one possibly being > DCEd already). > > Another issue is that of propagation. We are happily replacing > > int * __restrict p = a; > *p = *b; > > with > > *a = *b; > > but you can't reply on all uses of 'p' being replaced, so you > might get an invalid mix of accesses via the restrict qualified > and the not restrict qualified pointer from the initializer. A simple and safe way is to forget __restrict on "p" if it is replaced by "a". Or in some limited sceinaros, there is no memory access or any address computation on "a" before assignment of "p = a" and after assignment of "a", we also set "a" as __restrict.