<div dir="ltr">On 15 February 2013 05:49, Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="im">struct { int A[100]; int B[100]} S;<br></div><div class="im"><div><br>
</div></div><div>ptr = gep S, 0, 0, x</div><div>ptr2 = gep S, 0, 1, y</div><div><br></div><div>= load ptr, !tbaa !"structS::A"</div><div>= load ptr2, !tbaa !"structS::B"</div><div><br></div><div>using this you could tell that ptr and ptr2 do not alias without knowing about x and y. Assuming certain language guarantees, which I don't know we could assume :).</div>
</div></blockquote><div><br></div><div style>Without inspecting the induction range and step, I don't know if you can ever say they don't alias.</div><div style><br></div><div style>C allows you to do:</div><div style>
<br></div><div style>A[150] = B[51];</div><div style><br></div><div style>And if you rely only on the type being different, you might say then don't alias, when they actually do.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>So for the following example it will conservatively say arrayidx and arrayidx2 alias?<br></div><div><br></div><div>%struct.anon = type { [256 x i64], i64, [256 x i64] }</div><div><br>
</div><div>define void @foo(i32 %x, i32 %y) {</div><div><div>  %arrayidx = getelementptr inbounds %struct.anon* @Foo, i32 0, i32 0, i32 %x</div><div>  %0 = store i64* %arrayidx, align 8</div><div>  %arrayidx2 = getelementptr inbounds %struct.anon* @Foo, i32 0, i32 2, i32 %y</div>
<div>  %1 = store i64* %arrayidx2, align 8</div><div>}</div></div></div></blockquote><div><br></div><div style>It's still valid C to do A[300] and end up reading B.</div><div style><br></div><div style>In that form, I'd never try to do anything with that function, not without enough RT checks. ;)</div>
<div style><br></div><div style>--renato</div></div></div></div>