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 For: | Operators | Syntax | Corresponding Intrinsic | Additional Intrinsic (Applies to All) |
---|---|---|---|---|
Equality |
select_eq |
R = select_eq(A, B, C, D) |
_mm_cmpeq_pi32 |
_mm_and_si64 |
Inequality |
select_neq |
R = select_neq(A, B, C, D) |
_mm_cmpeq_pi32 |
|
Greater Than |
select_gt |
R = select_gt(A, B, C, D) |
_mm_cmpgt_pi32 |
|
Greater
Than |
select_ge |
R = select_gt(A, B, C, D) |
_mm_cmpge_pi32 |
|
Less Than |
select_lt |
R = select_lt(A, B, C, D) |
_mm_cmplt_pi32 |
|
Less Than |
select_le |
R = select_le(A, B, C, D) |
_mm_cmple_pi32 |
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.
R | Comparison | A and B | C | D |
---|---|---|---|---|
I32vec2 R |
select_eq |
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 |
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.
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; |