<div dir="ltr">On 15 February 2013 12:57, Arnold <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 dir="auto"><div>Yes this is where I am not sure whether C's strict aliasing would allow or forbid that kind of access.<br>
</div><div><br></div><div>I know it forbids a float * aliasing an int * but it does it forbit struct.a[x] aliasing struct.b[x]?<br><div><br></div><div>If it allows it then yes all my example won't work. You would need a different language that had such a semantic that would guarantee that such accesses are not allowed.</div>
</div></div></blockquote><div><br></div><div style>So, beyond the range of the first array, the behaviour is undefined, which means we can vectorize, even if it does alias, with the excuse that it's better to get it fast where it does matter (defined behaviour) than get correct where it doesn't (undefined behaviour).</div>
<div style><br></div><div style>As far as I could see, GCC takes this approach on the examples I attach, and it gets one of the out-of-bounds writes too early (as expected, when aliasing).</div><div style><br></div><div style>
I'm inclined not to mess with aliasing ranges, even if the behaviour is undefined, at least for now, for two reasons:</div><div style><br></div><div style>1. LLVM doesn't distinguish between GEP accesses, and can only know what is being accessed (and the possible range) with TBAA. We're already going on step beyond, using bassic AA, I don't want to give two steps at the same time</div>
<div style><br></div><div style>2. As I'm being overly conservative, for now, I prefer to keep the behaviour identical to the non-vectorized code, than risk an avalanche of bug reports, even if they mean undefined behaviour. Since we're changing something delicate, I'd rather make sure it's solid, before start changing undefined behaviour.</div>
<div style><br></div><div style>So, on this first attempt, I'll bail on the smallest possibility of static aliasing. Of the 7 cases in the attached example, I just want to vectorize the first now.</div><div style><br>
</div><div style>cheers,</div><div style>--renato</div></div></div></div>