[LLVMdev] Instruction pattern type inference problem

Christopher Lamb christopher.lamb at gmail.com
Tue Apr 24 08:10:09 PDT 2007

On Apr 24, 2007, at 8:09 AM, Morten Ofstad wrote:

> Christopher Lamb wrote:
>> A strategy that we have had luck with in the past is the concept of a
>> "vector boolean" type, which is the result of a comparison between  
>> two
>> vectors. It's then necessary to perform a reduction (and, or) on the
>> elements in order to produce a scalar boolean value that's  
>> suitable for
>> a branch. This also allows stuff like letting 'select' accept a  
>> vector
>> boolean predicate and vector values to perform a vector select.
> this is the semantics that GLSL uses for vector compares, for  
> example the signature of one of the overloads for the
> built-in function 'lessThan' is:
> bvec4 lessThan(vec4 x, vec4 y)
> what I wanted to mention are the built-in functions 'any' and 'all'  
> which have signatures (for 4-vectors)
> bool any(bvec4 x)
> bool all(bvec4 x)
> and the obvious semantics any(x)= x.x || x.y || x.z || x.w and all 
> (x)= x.x && x.y && x.z && x.w -- I think if vector
> comparisions and vector boolean types are added to LLVM, it would  
> also be very nice to have the 'any' and 'all' added as
> intrinsics...

This is precisely the approach that we took. Programmers can pretty  
easily wrap their head around the idea of vector bools.

Christopher Lamb

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070424/cbdf40ca/attachment.html>

More information about the llvm-dev mailing list