[LLVMdev] branch on vector compare?

Stephen suasol at gmail.com
Mon Sep 3 15:08:55 PDT 2012

> > which goes through memory. Is there some idiom I'm missing so that it would 
> > for instance movmsk for SSE or vcmpgt & cr6 for altivec?
> I don't think you are missing anything: LLVM IR has no support for horizontal
> operations like or'ing the elements of a vector of boolean together.  The code
> generators do try to recognize a few idioms and synthesize horizontal
> operations from them, but I think only addition is currently recognized, and

Thanks Duncan,

you're right - that does compile to a mess of spills to memory not
unlike the original.

I went to have a look at this further: It seems the existing SelectInst
is pretty close to what is needed.
Value IRBuilder::*CreateSelect(Value *C, Value *True, Value *False,
const Twine &Name)
Currently, this asserts that the True & False are both vector types of
the same size as "C". I was thinking of weakening this condition so that
if True and False are both i1 types, it will be allowed and will result
in something which can be branched on.

I have quite a bit of reading ahead it seems!

More information about the llvm-dev mailing list