[llvm-dev] SLP example not being vectorized

Adrien Guinet via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 28 10:43:32 PST 2019


On 11/28/19 6:45 PM, Sandoval Gonzalez, Leonardo via llvm-dev wrote:
> Hi,
> 
> I am new to llvm with a particular interested in the optimization area,
> specially on SLP. While working through the tutorial, I ran this example
> [1] with the hope to see SLP vectorization in action but for some
> reason, I do not see it on the LLVM assembly as seen below. Is there
> anything I am missing? I am using Clearlinux as build machine and this
> has clang version 9.0.0.
> 


If you're on Intel hardware, I'd say that AFAIK there is no vectorial
integer division instruction, so LLVM won't vectorize this code.
Moreover, you should specify which instruction set you want to use,
whether by specifying the CPU architecure with -march, or by activating
various instruction sets by "hand" (e.g. with -mavx2).

For instance, the SLP vectorizer will work here:

$ cat a.c
void foo(int a1, int a2, int b1, int b2, int *A) {
  A[0] = a1+a2;
  A[1] = b1+b2;
  A[2] = a1+b2;
  A[3] = a2+b1;
  A[4] = a2+a2;
  A[5] = b2+b2;
  A[6] = a2+b2;
  A[7] = a1+b1;
}

$ clang-9 -S -emit-llvm -O3 -march=native -o - a.c
define dso_local void @foo(i32, i32, i32, i32, i32* nocapture)
local_unnamed_addr #0 {
 [...]
  %20 = add nsw <8 x i32> %13, %19
  [...]
}


More information about the llvm-dev mailing list