[LLVMdev] Vector comparisons
Gordon Henriksen
gordonhenriksen at mac.com
Fri Jan 19 06:35:42 PST 2007
Are the ICMP and FCMP instructions meant to accept vectors operands
or no? Verifier excludes vectors, as does the AsmParser[1]. But the
CmpInst constructor accepts vectors[2], and they are documented as
allowed:
> If the operands [of icmp or fcmp] are packed typed, the elements of
> the vector are compared in turn and the predicate must hold for all
> elements.
— Gordon
[1]
% llvm-as <<'EOT' >/dev/null
define i1 %cmpvint(<4 x i32> %x, <4 x i32> %y) {
%res = icmp eq <4 x i32> %y, %y
ret %res
}
EOT
llvm-as: <stdin>:2,0: Packed types not supported by icmp instruction
% llvm-as <<'EOT' >/dev/null
define i1 %cmpfint(<4 x float> %x, <4 x float> %y) {
%res = fcmp oeq <4 x float> %y, %y
ret %res
}
EOT
llvm-as: <stdin>:2,0: Packed types not supported by fcmp instruction
[2] From CmpInst::CmpInst:
// Check that the operands are the right type
assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
(isa<PackedType>(Op0Ty) &&
cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
"Invalid operand types for ICmp instruction");
...
// Check that the operands are the right type
assert(Op0Ty->isFloatingPoint() || (isa<PackedType>(Op0Ty) &&
cast<PackedType>(Op0Ty)->getElementType()->isFloatingPoint
()) &&
"Invalid operand types for FCmp instruction");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070119/9eebe530/attachment.html>
More information about the llvm-dev
mailing list