[LLVMdev] passing vector of booleans to functions

Duncan Sands baldrick at free.fr
Tue Feb 26 01:02:22 PST 2013


Hi Roland,

 > define <4 x float> @masked_add_1(<4 x i1> %mask, <4 x float> %a, <4 x float> 
%b) {
> entry:
>    %add = fadd <4 x float> %a, %b
>    %sel = select <4 x i1> %mask, <4 x float> %add, <4 x float> %a
>    ret <4 x float> %sel
> }
>
> I will get:
>
> addps   %xmm1, %xmm2
> pslld   $31, %xmm0
> blendvps    %xmm2, %xmm1
> movaps  %xmm1, %xmm0
> ret
>
> While this is correct and works, I'm unhappy with the pssld. Apparently,
> LLVM uses a <4 x i32> to hold the <4 x i1> while the LSB holds the mask
> bit. But blendvps expects the MSB as mask bit and therefore the shift.

try plunking a signext attribute on the mask parameter.  That's supposed to tell
the code generators that the caller passed in an all-zero or all-one value.

Ciao, Duncan.



More information about the llvm-dev mailing list