[llvm-dev] unable to emit vectorized code in LLVM IR

hameeza ahmed via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 16 14:38:24 PDT 2017


Hello,
I have written the following code. when i try to vectorize it through opt.
i am not getting vectorized instructions.

#include <stdio.h>
#include<stdlib.h>
int main(int argc, char** argv) {
int sum=0; int a=atoi(argv[1]); int b=atoi(argv[2]);
for (int i=0;i<1000;i++)
{
sum+=a+b;
}

printf("sum: %d\n", sum);
return 0;
}
i use following commands:
clang  -S -emit-llvm sum-main.c -march=knl -O3 -mllvm -disable-llvm-optzns
-o sum-main.ll
opt  -S -O3 -force-vector-width=64 sum-main.ll -o sum-main03.ll

why is that so? where am i doing mistake? i am not getting vectorized
operations rather getting scalar operations.

Please help.

Thank You

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170817/1b9a8490/attachment.html>


More information about the llvm-dev mailing list