<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> You don't have x1 and x2 in your example, assuming you mean:<br>
><br>
> int i = 0;<br>
> T A;<br>
> T * y2 = ...<br>
> {<br>
> T * x1 = &A;<br>
> a = x1[i];<br>
> }<br>
> {<br>
> T * restrict x2 = y2;<br>
> b = x2[i];<br>
> }<br>
><br>> It should, no? by virtue of x2 being restrict you know that *x2<br>
> doesn't alias A, and *x1 is A.<br>
<br>
No, it doesn't. The fact that x2 is restrict does not mean that it does not alias with any other potential accesses from variables live in its block. It only means it does not alias with other accesses with that occur in the block where x2 is live. There is no access to A or x1 in that block, so we can say nothing about it.<br></blockquote><div><br></div><div>It does. You can assume x2 is not aliased to A and still get well-defined semantics, precisely because A is not referenced in the scope of x2. That refinement would only get you into trouble if A is referenced in the scope of x2, which would trigger UB.</div><div><br></div><div>Going further, logically the intrinsic should return a pointer to a new object, disjoint from all other live objects. It is not aliased to A, and is well defined even if it contains &A because A is not referenced in the scope. This does require dataflow barriers on entrance/exits to the scope, but those can be made no worse than the original code.<br></div><div><br></div><div>Aliasing x2 to A is not only unnecessary, but also pessimistic because in general you do not have access to the dynamic scope of the restricted pointer.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
T A, B;<br>
T * x1 = .... // either &A or &B<br>
T * y2 = .... // maybe &A<br>
{<br>
T * restrict x2 = y2;<br>
*x1 = ...<br>
*x2 = ...<br>
}<br>
<br>
><br>> In this case you'll be able to tell *x1 doesn't alias *x2, right?<br>
<br>
In this case, yes, we can conclude that x1 and x2 don't alias (because *x1 and *x2 cannot both legally refer to the same object).<br>
<br>
> How about if you add restrict to x1?<br>
<br>
The conclusion is the same, but if you add restrict to x1, you don't need it on x2. x2 is definitely not based on x1, so if x1 is restrict, then we know that x1 and x2 don't alias.<br></blockquote><div><br></div><div>Agreed. So will your approach be able to catch both cases? It seemed to me it wouldn't be able to catch the second one because it would have a different scope, but probably I'm missing something. </div><div><br></div><div>Thanks for your patience,<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">><br>
<br>
--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</blockquote></div>