[LLVMdev] Vector comparisons

Reid Spencer rspencer at reidspencer.com
Fri Jan 19 08:04:25 PST 2007


Hi Gordon,

On Fri, 2007-01-19 at 09:35 -0500, Gordon Henriksen wrote:
> Are the ICMP and FCMP instructions meant to accept vectors operands or
> no? 

No.

> Verifier excludes vectors, as does the AsmParser[1]. 

Correct.

> But the CmpInst constructor accepts vectors[2], 

At one time we tried to get them working, guess that's a left over.

> 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.

I'll fix the documentation.

Originally we had plans for supporting vector comparisons of at least EQ
and NE predicates. The others don't really make sense. However, none of
the backends can handle it at this time. So, we made the verifier and
AsmParser exclude them.  Perhaps someday this will get supported and
turned on.  Open a PR if you need this.

Reid.

> 
> — 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");
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list