Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/31/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Comparison Operators

The equality and inequality comparison operands can have mixed signedness, but they must be of the same size. The comparison operators for less-than and greater-than must be of the same sign and size. For example:

  • The nearest common ancestor is returned for compare for equal/not-equal operations:
    Iu8vec8 A;
    Is8vec8 B;
    I8vec8 C;
    
    C = cmpneq(A,B);
    
  • Type cast needed for different-sized elements for equal/not-equal comparisons:
    Iu8vec8 A, C;
    Is16vec4 B;
    
    C = cmpeq(A,(Iu8vec8)B);
    
  • Type cast needed for sign or size differences for less-than and greater-than comparisons:
    Iu16vec4 A;
    Is16vec4 B, C;
    
    C = cmpge((Is16vec4)A,B);
    C = cmpgt(B,C);
    

Inequality Comparison Symbols and Corresponding Intrinsics

Comparison

Operators

Syntax

Intrinsic

Equality

cmpeq

R = cmpeq(A, B)

_mm_cmpeq_pi32
_mm_cmpeq_pi16
_mm_cmpeq_pi8

Inequality

cmpneq

R = cmpneq(A, B)

_mm_cmpeq_pi32
_mm_cmpeq_pi16
_mm_cmpeq_pi8
_mm_andnot_si64

Greater Than

cmpgt

R = cmpgt(A, B)

_mm_cmpgt_pi32
_mm_cmpgt_pi16
_mm_cmpgt_pi8

Greater Than
or Equal To

cmpge

R = cmpge(A, B)

_mm_cmpgt_pi32
_mm_cmpgt_pi16
_mm_cmpgt_pi8
_mm_andnot_si64

Less Than

cmplt

R = cmplt(A, B)

_mm_cmpgt_pi32
_mm_cmpgt_pi16
_mm_cmpgt_pi8

Less Than
or Equal To

cmple

R = cmple(A, B)

_mm_cmpgt_pi32
_mm_cmpgt_pi16
_mm_cmpgt_pi8
_mm_andnot_si64

Compare Operator Overloading

Comparison operators have the restriction that the operands must be the size and sign as listed in the following table.

R

Comparison

Operand A

Operand B

I32vec2 R

cmpeq
cmpne

I[s|u]32vec2 B

I[s|u]32vec2 B

I16vec4 R

 

I[s|u]16vec4 B

I[s|u]16vec4 B

I8vec8 R

 

I[s|u]8vec8 B

I[s|u]8vec8 B

I32vec2 R

cmpgt
cmpge
cmplt
cmple

Is32vec2 B

Is32vec2 B

I16vec4 R

 

Is16vec4 B

Is16vec4 B

I8vec8 R

 

Is8vec8 B

Is8vec8 B