[LLVMdev] Vector code

B. Scott Michel scottm at aero.org
Wed May 14 15:58:17 PDT 2008


 From the cellspu's test harnesses:


define <4 x float> @fp_add_vec(<4 x float> %arg1, <4 x float> %arg2) {
%A = add <4 x float> %arg1, %arg2
ret <4 x float> %A
}

It's a simple vector add for two v4f32 quantities. There are things you 
need to do in order to make the optimizer not optimize, e.g.:

v4f32 fp_add_vec(v4f32 arg1, v4f32 arg2) {
return arg1 + arg2;
}

Hope this helps.


-scooter

Nicolas Capens wrote:
>
> Hi all,
>
> I’m trying to use LLVM to generate SIMD code at runtime (in particular 
> Intel SSE). But I’m having a bit of trouble understanding how to 
> create even the simplest function; adding two vectors of four 
> single-precision floating-point elements. I can get it to add the 
> elements one at a time but not using one vector instruction.
>
> All help much appreciated!
>
> Nicolas Capens
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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