[LLVMdev] Vector code

Nicolas Capens nicolas at capens.net
Fri May 9 03:27:36 PDT 2008


Hi Frits,

Thanks for the suggestions! I was first able to successfully compile it to
bitcode (.bc format). llc doesn't support "-march=cpp", but then I ran
llvm2cpp which does give me the C++ code to directly create the intermediate
representation. Now I can study that to see what I was doing wrong
earlier...

Thanks again!

-Nicolas


-----Original Message-----
From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On
Behalf Of Frits van Bommel
Sent: Thursday, 08 May, 2008 23:56
To: LLVM Developers Mailing List
Subject: Re: [LLVMdev] Vector code

Nicolas Capens wrote:
> Here's essentially what I try to generate:
> 
> void add(float z[4], float x[4], float y[4])
> {
>    z[0] = x[0] + y[0];
>    z[1] = x[1] + y[1];
>    z[2] = x[2] + y[2];
>    z[3] = x[3] + y[3];
> }

This is the vectorized llvm-assembly equivalent:
-----
define void @add(<4 x float>* %z, <4 x float>* %x, <4 x float>* %y) {
entry:
     %xs = load <4 x float>* %x
     %ys = load <4 x float>* %y
     %zs = add <4 x float> %xs, %ys
     store <4 x float> %zs, <4 x float>* %z
     ret void
}
------
Run that through "llvm-as < code.ll | llc -march=cpp" to see the code to 
construct it.
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list