-->

Conditional Select Operators

For conditional select operands, the third and fourth operands determine the type returned. Third and fourth operands with same size, but different signedness, return the nearest common ancestor data type.

Conditional Select Syntax Usage

/* Return the nearest common ancestor data type if third and fourth operands are of the same size, but different signs */

I16vec4 R = select_neq(Is16vec4, Is16vec4, Is16vec4, Iu16vec4);

/* Conditional Select for Equality */

R0 := (A0 == B0) ? C0 : D0;

R1 := (A1 == B1) ? C1 : D1;

R2 := (A2 == B2) ? C2 : D2;

R3 := (A3 == B3) ? C3 : D3;

/* Conditional Select for Inequality */

R0 := (A0 != B0) ? C0 : D0;

R1 := (A1 != B1) ? C1 : D1;

R2 := (A2 != B2) ? C2 : D2;

R3 := (A3 != B3) ? C3 : D3;

Conditional Select Symbols and Corresponding Intrinsics

Conditional Select For: Operators Syntax Corresponding Intrinsic Additional Intrinsic (Applies to All)
Equality select_eq R = select_eq(A, B, C, D) _mm_cmpeq_pi32
_mm_cmpeq_pi16
_mm_cmpeq_pi8
_mm_and_si64
_mm_or_si64
_mm_andnot_si64
Inequality select_neq R = select_neq(A, B, C, D) _mm_cmpeq_pi32
_mm_cmpeq_pi16
_mm_cmpeq_pi8

 

Greater Than select_gt R = select_gt(A, B, C, D) _mm_cmpgt_pi32
_mm_cmpgt_pi16
_mm_cmpgt_pi8

 

Greater Than
or Equal To
select_ge R = select_gt(A, B, C, D) _mm_cmpge_pi32
_mm_cmpge_pi16
_mm_cmpge_pi8

 

Less Than select_lt R = select_lt(A, B, C, D) _mm_cmplt_pi32
_mm_cmplt_pi16
_mm_cmplt_pi8

 

Less Than
or Equal To
select_le R = select_le(A, B, C, D) _mm_cmple_pi32
_mm_cmple_pi16
_mm_cmple_pi8

 

All conditional select operands must be of the same size. The return data type is the nearest common ancestor of operands C and D. For conditional select operations using greater-than or less-than operations, the first and second operands must be signed as listed in the table that follows.

Conditional Select Operator Overloading

R Comparison A and B C D
I32vec2 R select_eq
select_ne
I[s|u]32vec2 I[s|u]32vec2 I[s|u]32vec2
I16vec4 R I[s|u]16vec4 I[s|u]16vec4 I[s|u]16vec4
I8vec8 R I[s|u]8vec8 I[s|u]8vec8 I[s|u]8vec8
I32vec2 R select_gt
select_ge
select_lt
select_le
Is32vec2 Is32vec2 Is32vec2
I16vec4 R Is16vec4 Is16vec4 Is16vec4
I8vec8 R Is8vec8 Is8vec8 Is8vec8

The table below shows the mapping of return values from R0 to R7 for any number of elements. The same return value mappings also apply when there are fewer than four return values.

Conditional Select Operator Return Value Mapping

Return Value

A and B Operands

C and D operands

A0

Available Operators

B0
R0:= A0 == != > >= < <= B0 ? C0 : D0;
R1:= A0 == != > >= < <= B0 ? C1 : D1;
R2:= A0 == != > >= < <= B0 ? C2 : D2;
R3:= A0 == != > >= < <= B0 ? C3 : D3;
R4:= A0 == != > >= < <= B0 ? C4 : D4;
R5:= A0 == != > >= < <= B0 ? C5 : D5;
R6:= A0 == != > >= < <= B0 ? C6 : D6;
R7:= A0 == != > >= < <= B0 ? C7 : D7;