vectorization for X86

I’m trying to vectorize a simple C code. My problem is that I don’t quite understand the relationship between clang --target option and the cores mentioned in as well as other X86 related options (such as -mtune). Below are the command and the code that I’m trying to vectorize. The code compiles but I don’t see any vectors. What am I doing wrong? Any help is appreciated.

clang -S x.c --target=x86_64-pc-gnu -mtune=core-avx2 -o x.x86.s -fvectorize -fno-lax-vector-conversions -fslp-vectorize-aggressive -fslp-vectorize

#define N 32

int main () {

int a[N], b[N];
int c[N];

for (int i = 0; i < N; ++i)
c[i] = a[i] + b[i];

int sum=0;
for (int i = 0; i < N; ++i)
sum += c[i];

return sum;

You need to enable an optimization level, this vectorizes for me:

clang -S x.c --target=x86_64-pc-gnu -mtune=core-avx2 -O3 -S -o -

Thanks. It worked!

Hi. I don’t know how llvm works internally, but I guess the code you wrote don’t need any vectorization.
It’s probably because its completely memory bound and hardware prefetch will do the job for you.
You can force vectorization using some pragmas (I don’t remember which).