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

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. For example:

  • 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

The following table lists the conditional select symbols and their corresponding intrinsics:

Conditional Select

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

Conditional Select Operator Overloading

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 following table:

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

I8vec8 R

 

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

I8vec8 R

 

Is8vec8

Is8vec8

Conditional Select Operator Return Value Mapping

The following table lists 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 Operands

Available Operators

B Operands

C and D Operands

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;