[LLVMdev] vector compare
Claudio Basile
cbasile at tempo-da.com
Thu Dec 25 01:28:37 PST 2008
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.
---------------------------------------------------------------------------------------
Approach 1
----------------
define i1 @VectorCompare1(<4 x i32> %x, <4 x i32> %y) {
%1 = icmp eq <4 x i32> %x, %y
%2 = bitcast <4 x i1> %1 to i4
%3 = icmp eq i4 %2, 0
ret i1 %3
}
This fails with:
ssertion failed: (VT.getSizeInBits() ==
Operand.getValueType().getSizeInBits() && "Cannot BIT_CONVERT between
types of different sizes!"), function getNode, file SelectionDAG.cpp,
line 2218.
Approach 2
----------------
define i1 @VectorCompare2(<4 x i32> %x, <4 x i32> %y) {
%1 = icmp eq <4 x i32> %x, %y
%2 = extractelement <4 x i1> %1, i32 0
%3 = extractelement <4 x i1> %1, i32 1
%4 = extractelement <4 x i1> %1, i32 2
%5 = extractelement <4 x i1> %1, i32 3
%6 = or i1 %2, %3
%7 = or i1 %4, %5
%8 = or i1 %6, %7
ret i1 %8
}
This fails with:
Assertion failed: (isVector() && "Invalid vector type!"), function
getVectorNumElements, file /Users/cbasile/src/llvm-2.4/include/llvm/
CodeGen/ValueTypes.h, line 339.
Approach 3
----------------
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
---------------------------------------------------------------------------------------
I'd really appreciate if someone could help me with this.
Thanks
Claudio
More information about the llvm-dev
mailing list