<div dir="ltr">Nadav,<div><br></div><div>I believe<span style="font-family:arial,sans-serif;font-size:13.333333969116211px"> aligned accesses to unaligned pointers</span> is precisely the issue. Consider the function `add_u8S` before[1] and after[2] the loop vectorizer pass. There is no alignment assumption associated with %kernel_data prior to vectorization. I can't tell if it's the loop vectorizer or the codegen at fault, but the alignment assumption seems to sneak in somewhere.</div>
<div><br></div><div>v/r,</div><div>Josh</div><div><br></div><div>[1] <a href="http://pastebin.com/kc95WtGG">http://pastebin.com/kc95WtGG</a></div><div>[2] <a href="http://pastebin.com/VY3ZLVJK">http://pastebin.com/VY3ZLVJK</a></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 15, 2013 at 3:58 PM, Nadav Rotem <span dir="ltr"><<a href="mailto:nrotem@apple.com" target="_blank">nrotem@apple.com</a>></span> wrote:<br>
<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><div class="h5"><br><div><div>On Nov 15, 2013, at 12:36 PM, Renato Golin <<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 15 November 2013 20:24, Joshua Klontz <span dir="ltr"><<a href="mailto:josh.klontz@gmail.com" target="_blank">josh.klontz@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Agreed, is there a pass that will insert a runtime alignment check? Also, what's the easiest way to get at TargetTransformInfo::getRegisterBitWidth() so I don't have to hard code 32? Thanks!</div>

</blockquote><div></div></div><br></div><div class="gmail_extra">I think that's a fair question, and it's about safety. If you're getting this on the JIT, means we may be generating unsafe transformations on the vectorizer.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Arnold, Nadav, I don't remember seeing code to generate any run-time alignment checks on the incoming pointer, is there such a thing? If not, shouldn't we add one?</div>

</div></blockquote></div><div><br></div><div><br></div></div></div>If the the vectorizer generates aligned memory accesses to unaligned addresses then this is a serious bug.  But I don’t think that Josh said that the vectorizer generated aligned accesses to unaligned pointers. <div>
<br><div><div><div>There is no point in LLVM checking for alignment because if the memory is unaligned then the program will crash.  Users who want to crash with a readable error message can simply write code that checks the pointer (by masking the high bits and comparing to zero).  <br>
<br></div></div></div></div></div></blockquote></div><br></div>