vector compare

Hi all,

is there any way to compare two 128bit values?
I have tried 3 different approaches and they all fail with an internal assertion.
I'm running llvm 2.4 on x86 with the following command line:

> llvm-as test.ll -o test.bc
> llc test.bc -filetype=asm

I would expect the code generator to emit a sequence of SSE instructions.

Hi all,

is there any way to compare two 128bit values?
I have tried 3 different approaches and they all fail with an internal
assertion.
I'm running llvm 2.4 on x86 with the following command line:

> llvm-as test.ll -o test.bc
> llc test.bc -filetype=asm

I would expect the code generator to emit a sequence of SSE
instructions.

Approaches 1 and 2 depend on some stuff that hasn't really stabilized
yet... you should get much better results with vicmp.

define i1 @VectorCompare3(i128 %x, i128 %y) {
    %1 = icmp eq i128 %x, %y
    ret i1 %1
}

This fails with:

Cannot yet select: 0x10182b4: i8 = setcc 0x101844c, 0x10184d4, 0x100becc

The result isn't pretty, but this appears to work on x86 using a
recent SVN build... I wouldn't be surprised if this was fixed
post-2.4.

-Eli

Oh wait, I just realized vicmp is a post-2.4 thing... if you really
want to generate an SSE comparison using LLVM 2.4, you can use the x86
intrinsics, like @llvm.x86.sse2.pcmpeq.b.

-Eli

Thanks for your answer.
It looks like vicmp is part of LLVM 2.4. It is documented there, at least.
How do you suggest I use it to compare two vector operands?
I'd guess I could generate a mask by extracting the most significant bits in each words, but that approach doesn't work per my initial posting.

Claudio

Thanks for your answer.
It looks like vicmp is part of LLVM 2.4. It is documented there, at least.

Hmm, really? I don't see it at
LLVM Assembly Language Reference Manual. If it's there, then
it should work, I think.

How do you suggest I use it to compare two vector operands?
I'd guess I could generate a mask by extracting the most significant bits in
each words, but that approach doesn't work per my initial posting.

For the best code generation, I'd suggest using
@llvm.x86.sse.movmsk.ps. Something like icmp
eq(movmskps(vicmp(a,b)),0) should do the trick assuming a and b are <4
x i32>. As far as I know, there isn't any way to make LLVM generate
that without using the x86-specific intrinsic.

-Eli