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.
/* 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);
Compare For: | Operators | Syntax | Intrinsic | |
---|---|---|---|---|
Equality |
cmpeq |
R = cmpeq(A, B) |
_mm_cmpeq_pi32 |
|
Inequality |
cmpneq |
R = cmpneq(A, B) |
_mm_cmpeq_pi32 |
_mm_andnot_si64 |
Greater Than |
cmpgt |
R = cmpgt(A, B) |
_mm_cmpgt_pi32 |
|
Greater
Than |
cmpge |
R = cmpge(A, B) |
_mm_cmpgt_pi32 |
_mm_andnot_si64 |
Less Than |
cmplt |
R = cmplt(A, B) |
_mm_cmpgt_pi32 |
|
Less Than |
cmple |
R = cmple(A, B) |
_mm_cmpgt_pi32 |
_mm_andnot_si64 |
Comparison operators have the restriction that the operands must be the size and sign as listed in the Compare Operator Overloading table.
R | Comparison | A | B |
---|---|---|---|
I32vec2 R |
cmpeq |
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 |
Is32vec2 B |
Is32vec2 B |
I16vec4 R |
Is16vec4 B |
Is16vec4 B | |
I8vec8 R |
Is8vec8 B |
Is8vec8 B |