[LLVMdev] passing vector of booleans to functions

Roland Leißa leissa at cs.uni-saarland.de
Tue Feb 26 05:18:32 PST 2013


Hi Duncan,

thanks for the hint. I tried both variants:

define <4 x float> @masked_add_1(<4 x i1> signext %mask, <4 x float> %a, <4 x 
float> %b)
define <4 x float> @masked_add_32(<4 x i32> %mask, <4 x float> %a, <4 x float> %b)

Unfortunately, this will raise an assertion:
Wrong types for attribute: zeroext signext noalias nocapture sret byval nest


Should I file a bug report?

-- 
Roland

On Tuesday 26 February 2013 10:02:22 Duncan Sands wrote:
> 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.
> _______________________________________________
> 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