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

Nemanja Ivanovic via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 16 22:44:50 PDT 2017


I'm not sure what you expect to have vectorized here. If you look at the
emitted code, there's no loop. It's just an add and a multiply as you might
expect when adding a loop-invariant sum 1000 times in a loop.

On Wed, Aug 16, 2017 at 11:38 PM, hameeza ahmed via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> 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
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170817/fb128e6d/attachment.html>


More information about the llvm-dev mailing list