<div dir="ltr"><div><div>Hi Dimitry -<br><br></div>This is an x86 backend bug, so the optimized (vectorized) IR should be all that is needed to reproduce the bug. I've filed this as PR27973:<br><a href="https://llvm.org/bugs/show_bug.cgi?id=27973">https://llvm.org/bugs/show_bug.cgi?id=27973</a><br><br><br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 1, 2016 at 3:09 PM, Dimitry Andric <span dir="ltr"><<a href="mailto:dimitry@andric.com" target="_blank">dimitry@andric.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 30 Mar 2016, at 21:37, Hal Finkel via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: hfinkel<br>
> Date: Wed Mar 30 14:37:08 2016<br>
> New Revision: 264904<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264904&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264904&view=rev</a><br>
> Log:<br>
> [LoopVectorize] Don't vectorize loops when everything will be scalarized<br>
</span>...<br>
<span class="">> This is not a problem specific to PPC/QPX, however. The problem comes up under<br>
> SSE on x86 too, and as such, this change fixes PR26837 too. I've added Sanjay's<br>
> reduced test case from PR26837 to this commit.<br>
<br>
</span>Hi Hal,<br>
<br>
I am investigating an assertion failure reported by Guido Falsi, which occurs during compilation of a certain FreeBSD port with clang 3.8.0 (the version we currently have in FreeBSD 11).  This assertion is:<br>
<br>
Assertion failed: (Subtarget.hasSSE2() && "Requires at least SSE2!"), function ReplaceNodeResults, file lib/Target/X86/X86ISelLowering.cpp, line 21400.<br>
<br>
Interestingly, this assertion was fixed in later versions of llvm trunk, and bisecting shows that it appears to be "fixed" by your r264904.  However, maybe this just exposed some problem in the vectorizer, and this problem is now masked by your commit?<br>
<br>
The reduced test case is just this:<br>
<br>
int a, b;<br>
void fn1() {<br>
  char *c;<br>
  unsigned char *d;<br>
  int e = b;<br>
  for (int y = 0; y < a; y = 2)<br>
    for (int i; i < e; i++) {<br>
      *c++ = (d[e] + 1) / 2;<br>
      d++;<br>
    }<br>
}<br>
<br>
and the minimal command line to make it assert (with clang 3.8.0 or trunk before r264904) is:<br>
<br>
clang -cc1 -triple i386 -emit-obj -target-cpu pentium3 -O1 -vectorize-loops testcase.cpp<br>
<br>
The important parts are: the pentium3 target, and -vectorize-loops.  If you use pentium2 or pentium4, it does *not* assert.<br>
<br>
Do you know of a way to 'undo' your commit, in the sense that you somehow *force* llvm to vectorize the loop?  I suspect there is some sort of incorrect usage of SSE2, specifically with the Pentium3 target, which blows something up...<br>
<span class="HOEnZb"><font color="#888888"><br>
-Dimitry<br>
<br>
</font></span></blockquote></div><br></div>