Are you counting unions, or literally just structs?<div><br></div><br><div class="gmail_quote">On Tue Jan 20 2015 at 12:34:38 PM Ahmed Bougacha <<a href="mailto:ahmed.bougacha@gmail.com">ahmed.bougacha@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
This is covered by (struct-path aware) TBAA, but BasicAA disagrees.<br>
See the attached testcase, where it prevents us from removing the<br>
redundant load.<br>
For arbitrary GEPs, we can't decide based on constant indices (because<br>
of e.g., &A[0][1] and &A[1][0], with *A a one-element array). BasicAA<br>
has some logic to "try to distinguish something like &A[i][1] against<br>
&A[42][0]". For the testcase, it works for instance when the struct<br>
has an even number of floats.<br>
<br>
However, I think we can safely say GEPs with different constant<br>
indices into a struct can't alias, at least when:<br>
- the GEP is inbounds<br>
- the access sizes are such that there is no overlap<br>
- the struct index is the final one<br>
<br>
That is, these can't alias:<br>
gep i1, j1, k1, 0<br>
gep i2, j2, k2, 1<br>
If this is a struct pointer:<br>
gep i1, j1, k1<br>
<br>
I couldn't come up with a counterexample that would prevent us from<br>
doing this in BasicAA.<br>
I was surprised it wasn't; surely I missed something?<br>
<br>
Thanks!<br>
<br>
-Ahmed<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></div>