Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

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

Document Table of Contents

Compare Intrinsics

The prototypes for Intel® Streaming SIMD Extensions (Intel® SSE) intrinsics for comparison operations are in the xmmintrin.h header file.

To use these intrinsics, include the immintrin.h file as follows:

#include <immintrin.h>

Each comparison intrinsic performs a comparison of a and b. For the packed form, the four single-precision FP values of a and b are compared, and a 128-bit mask is returned. For the scalar form, the lower single-precision FP values of a and b are compared, and a 32-bit mask is returned; the upper three single-precision FP values are passed through from a. The mask is set to 0xffffffff for each element where the comparison is true and 0x0 where the comparison is false.

The results of each intrinsic operation are placed in a register. This register is illustrated for each intrinsic with R or R0-R3. R0, R1, R2, and R3 each represent one of the four 32-bit pieces of the result register.

Intrinsic Name

Operation

Corresponding
Intel® SSE Instruction

_mm_cmpeq_ss

Equal

CMPEQSS

_mm_cmpeq_ps

Equal

CMPEQPS

_mm_cmplt_ss

Less Than

CMPLTSS

_mm_cmplt_ps

Less Than

CMPLTPS

_mm_cmple_ss

Less Than or Equal

CMPLESS

_mm_cmple_ps

Less Than or Equal

CMPLEPS

_mm_cmpgt_ss

Greater Than

CMPLTSS

_mm_cmpgt_ps

Greater Than

CMPLTPS

_mm_cmpge_ss

Greater Than or Equal

CMPLESS

_mm_cmpge_ps

Greater Than or Equal

CMPLEPS

_mm_cmpneq_ss

Not Equal

CMPNEQSS

_mm_cmpneq_ps

Not Equal

CMPNEQPS

_mm_cmpnlt_ss

Not Less Than

CMPNLTSS

_mm_cmpnlt_ps

Not Less Than

CMPNLTPS

_mm_cmpnle_ss

Not Less Than or Equal

CMPNLESS

_mm_cmpnle_ps

Not Less Than or Equal

CMPNLEPS

_mm_cmpngt_ss

Not Greater Than

CMPNLTSS

_mm_cmpngt_ps

Not Greater Than

CMPNLTPS

_mm_cmpnge_ss

Not Greater Than or Equal

CMPNLESS

_mm_cmpnge_ps

Not Greater Than or Equal

CMPNLEPS

_mm_cmpord_ss

Ordered

CMPORDSS

_mm_cmpord_ps

Ordered

CMPORDPS

_mm_cmpunord_ss

Unordered

CMPUNORDSS

_mm_cmpunord_ps

Unordered

CMPUNORDPS

_mm_comieq_ss

Equal

COMISS

_mm_comilt_ss

Less Than

COMISS

_mm_comile_ss

Less Than or Equal

COMISS

_mm_comigt_ss

Greater Than

COMISS

_mm_comige_ss

Greater Than or Equal

COMISS

_mm_comineq_ss

Not Equal

COMISS

_mm_ucomieq_ss

Equal

UCOMISS

_mm_ucomilt_ss

Less Than

UCOMISS

_mm_ucomile_ss

Less Than or Equal

UCOMISS

_mm_ucomigt_ss

Greater Than

UCOMISS

_mm_ucomige_ss

Greater Than or Equal

UCOMISS

_mm_ucomineq_ss

Not Equal

UCOMISS

_mm_cmpeq_ss

__m128 __cdecl _mm_cmpeq_ss(__m128 a, __m128 b);

Compares for equality.

R0

R1

R2

R3

(a0 == b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpeq_ps

__m128 _mm_cmpeq_ps(__m128 a, __m128 b);

Compares for equality.

R0

R1

R2

R3

(a0 == b0) ? 0xffffffff : 0x0

(a1 == b1) ? 0xffffffff : 0x0

(a2 == b2) ? 0xffffffff : 0x0

(a3 == b3) ? 0xffffffff : 0x0

_mm_cmplt_ss

__m128 _mm_cmplt_ss(__m128 a, __m128 b);

Compares for less-than.

R0

R1

R2

R3

(a0 < b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmplt_ps

__m128 _mm_cmplt_ps(__m128 a, __m128 b);

Compares for less-than.

R0

R1

R2

R3

(a0 < b0) ? 0xffffffff : 0x0

(a1 < b1) ? 0xffffffff : 0x0

(a2 < b2) ? 0xffffffff : 0x0

(a3 < b3) ? 0xffffffff : 0x0

_mm_cmple_ss

__m128 _mm_cmple_ss(__m128 a, __m128 b);

Compares for less-than-or-equal.

R0

R1

R2

R3

(a0 <= b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmple_ps

__m128 _mm_cmple_ps(__m128 a, __m128 b);

Compares for less-than-or-equal.

R0

R1

R2

R3

(a0 <= b0) ? 0xffffffff : 0x0

(a1 <= b1) ? 0xffffffff : 0x0

(a2 <= b2) ? 0xffffffff : 0x0

(a3 <= b3) ? 0xffffffff : 0x0

_mm_cmpgt_ss

__m128 _mm_cmpgt_ss(__m128 a, __m128 b);

Compares for greater-than.

R0

R1

R2

R3

(a0 > b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpgt_ps

__m128 _mm_cmpgt_ps(__m128 a, __m128 b);

Compares for greater-than.

R0

R1

R2

R3

(a0 > b0) ? 0xffffffff : 0x0

(a1 > b1) ? 0xffffffff : 0x0

(a2 > b2) ? 0xffffffff : 0x0

(a3 > b3) ? 0xffffffff : 0x0

_mm_cmpge_ss

__m128 _mm_cmpge_ss(__m128 a, __m128 b);

Compares for greater-than-or-equal.

R0

R1

R2

R3

(a0 >= b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpge_ps

__m128 _mm_cmpge_ps(__m128 a, __m128 b);

Compares for greater-than-or-equal.

R0

R1

R2

R3

(a0 >= b0) ? 0xffffffff : 0x0

(a1 >= b1) ? 0xffffffff : 0x0

(a2 >= b2) ? 0xffffffff : 0x0

(a3 >= b3) ? 0xffffffff : 0x0

_mm_cmpneq_ss

__m128 _mm_cmpneq_ss(__m128 a, __m128 b);

Compares for inequality.

R0

R1

R2

R3

(a0 != b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpneq_ps

__m128 _mm_cmpneq_ps(__m128 a, __m128 b);

Compares for inequality.

R0

R1

R2

R3

(a0 != b0) ? 0xffffffff : 0x0

(a1 != b1) ? 0xffffffff : 0x0

(a2 != b2) ? 0xffffffff : 0x0

(a3 != b3) ? 0xffffffff : 0x0

_mm_cmpnlt_ss

__m128 _mm_cmpnlt_ss(__m128 a, __m128 b);

Compares for not-less-than.

R0

R1

R2

R3

!(a0 < b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpnlt_ps

__m128 _mm_cmpnlt_ps(__m128 a, __m128 b);

Compares for not-less-than.

R0

R1

R2

R3

!(a0 < b0) ? 0xffffffff : 0x0

!(a1 < b1) ? 0xffffffff : 0x0

!(a2 < b2) ? 0xffffffff : 0x0

!(a3 < b3) ? 0xffffffff : 0x0

_mm_cmpnle_ss

__m128 _mm_cmpnle_ss(__m128 a, __m128 b);

Compares for not-less-than-or-equal.

R0

R1

R2

R3

!(a0 <= b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpnle_ps

__m128 _mm_cmpnle_ps(__m128 a, __m128 b);

Compares for not-less-than-or-equal.

R0

R1

R2

R3

!(a0 <= b0) ? 0xffffffff : 0x0

!(a1 <= b1) ? 0xffffffff : 0x0

!(a2 <= b2) ? 0xffffffff : 0x0

!(a3 <= b3) ? 0xffffffff : 0x0

_mm_cmpngt_ss

__m128 _mm_cmpngt_ss(__m128 a, __m128 b);

Compares for not-greater-than.

R0

R1

R2

R3

!(a0 > b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpngt_ps

__m128 _mm_cmpngt_ps(__m128 a, __m128 b);

Compares for not-greater-than.

R0

R1

R2

R3

!(a0 > b0) ? 0xffffffff : 0x0

!(a1 > b1) ? 0xffffffff : 0x0

!(a2 > b2) ? 0xffffffff : 0x0

!(a3 > b3) ? 0xffffffff : 0x0

_mm_cmpnge_ss

__m128 _mm_cmpnge_ss(__m128 a, __m128 b);

Compares for not-greater-than-or-equal.

R0

R1

R2

R3

!(a0 >= b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpnge_ps

__m128 _mm_cmpnge_ps(__m128 a, __m128 b);

Compares for not-greater-than-or-equal.

R0

R1

R2

R3

!(a0 >= b0) ? 0xffffffff : 0x0

!(a1 >= b1) ? 0xffffffff : 0x0

!(a2 >= b2) ? 0xffffffff : 0x0

!(a3 >= b3) ? 0xffffffff : 0x0

_mm_cmpord_ss

__m128 _mm_cmpord_ss(__m128 a, __m128 b);

Compares for ordered.

R0

R1

R2

R3

(a0 ord? b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpord_ps

__m128 _mm_cmpord_ps(__m128 a, __m128 b);

Compares for ordered.

R0

R1

R2

R3

(a0 ord? b0) ? 0xffffffff : 0x0

(a1 ord? b1) ? 0xffffffff : 0x0

(a2 ord? b2) ? 0xffffffff : 0x0

(a3 ord? b3) ? 0xffffffff : 0x0

_mm_cmpunord_ss

__m128 _mm_cmpunord_ss(__m128 a, __m128 b);

Compares for unordered.

R0

R1

R2

R3

(a0 unord? b0) ? 0xffffffff : 0x0

a1

a2

a3

_mm_cmpunord_ps

__m128 _mm_cmpunord_ps(__m128 a, __m128 b);

Compares for unordered.

R0

R1

R2

R3

(a0 unord? b0) ? 0xffffffff : 0x0

(a1 unord? b1) ? 0xffffffff : 0x0

(a2 unord? b2) ? 0xffffffff : 0x0

(a3 unord? b3) ? 0xffffffff : 0x0

_mm_comieq_ss

int _mm_comieq_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a equal to b. If a and b are equal, 1 is returned. Otherwise, 0 is returned.

R

(a0 == b0) ? 0x1 : 0x0

_mm_comilt_ss

int _mm_comilt_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a less than b. If a is less than b, 1 is returned. Otherwise, 0 is returned.

R

(a0 < b0) ? 0x1 : 0x0

_mm_comile_ss

int _mm_comile_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a less than or equal to b. If a is less than or equal to b, 1 is returned. Otherwise, 0 is returned.

R

(a0 <= b0) ? 0x1 : 0x0

_mm_comigt_ss

int _mm_comigt_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a greater than b. If a is greater than b are equal, 1 is returned. Otherwise, 0 is returned.

R

(a0 > b0) ? 0x1 : 0x0

_mm_comige_ss

int _mm_comige_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a greater than or equal to b. If a is greater than or equal to b, 1 is returned. Otherwise, 0 is returned.

R

(a0 >= b0) ? 0x1 : 0x0

_mm_comineq_ss

int _mm_comineq_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a not equal to b. If a and b are not equal, 1 is returned. Otherwise, 0 is returned.

R

(a0 != b0) ? 0x1 : 0x0

_mm_ucomieq_ss

int _mm_ucomieq_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a equal to b. If a and b are equal, 1 is returned. Otherwise, 0 is returned.

R

(a0 == b0) ? 0x1 : 0x0

_mm_ucomilt_ss

int _mm_ucomilt_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a less than b. If a is less than b, 1 is returned. Otherwise, 0 is returned.

R

(a0 < b0) ? 0x1 : 0x0

_mm_ucomile_ss

int _mm_ucomile_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a less than or equal to b. If a is less than or equal to b, 1 is returned. Otherwise, 0 is returned.

R

(a0 <= b0) ? 0x1 : 0x0

_mm_ucomigt_ss

int _mm_ucomigt_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a greater than b. If a is greater than or equal to b, 1 is returned. Otherwise, 0 is returned.

R

(a0 > b0) ? 0x1 : 0x0

_mm_ucominge_ss

int _mm_ucomige_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a greater than or equal to b. If a is greater than or equal to b, 1 is returned. Otherwise, 0 is returned.

R

(a0 >= b0) ? 0x1 : 0x0

_mm_ucomineq_ss

int _mm_ucomineq_ss(__m128 a, __m128 b);

Compares the lower SP FP value of a and b for a not equal to b. If a and b are not equal, 1 is returned. Otherwise, 0 is returned.

R

r := (a0 != b0) ? 0x1 : 0x0