[llvm] r264904 - [LoopVectorize] Don't vectorize loops when everything will be scalarized

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 14:09:40 PDT 2016


On 30 Mar 2016, at 21:37, Hal Finkel via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: hfinkel
> Date: Wed Mar 30 14:37:08 2016
> New Revision: 264904
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=264904&view=rev
> Log:
> [LoopVectorize] Don't vectorize loops when everything will be scalarized
...
> This is not a problem specific to PPC/QPX, however. The problem comes up under
> SSE on x86 too, and as such, this change fixes PR26837 too. I've added Sanjay's
> reduced test case from PR26837 to this commit.

Hi Hal,

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:

Assertion failed: (Subtarget.hasSSE2() && "Requires at least SSE2!"), function ReplaceNodeResults, file lib/Target/X86/X86ISelLowering.cpp, line 21400.

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?

The reduced test case is just this:

int a, b;
void fn1() {
  char *c;
  unsigned char *d;
  int e = b;
  for (int y = 0; y < a; y = 2)
    for (int i; i < e; i++) {
      *c++ = (d[e] + 1) / 2;
      d++;
    }
}

and the minimal command line to make it assert (with clang 3.8.0 or trunk before r264904) is:

clang -cc1 -triple i386 -emit-obj -target-cpu pentium3 -O1 -vectorize-loops testcase.cpp

The important parts are: the pentium3 target, and -vectorize-loops.  If you use pentium2 or pentium4, it does *not* assert.

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...

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160601/b9df181b/attachment.sig>


More information about the llvm-commits mailing list