# Compare Intrinsics

Intel® Streaming SIMD Extensions 2 (Intel® SSE2) intrinsics for integer comparison operations are listed in this topic. The prototypes for Intel® SSE2 intrinsics are in the emmintrin.h header file.

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

    #include <immintrin.h>

The results of each intrinsic operation are placed in registers. The information about what is placed in each register appears in the tables below, in the detailed explanation of each intrinsic. R, R0, R1, ...,R15 represent the registers in which results are placed.

Intrinsic Name | Operation | Corresponding Intel® SSE2 Instruction
--- | --- | ---
_mm_cmpeq_epi8 | Equality | PCMPEQB
_mm_cmpeq_epi16 | Equality | PCMPEQW
_mm_cmpeq_epi32 | Equality | PCMPEQD
_mm_cmpgt_epi8 | Greater Than | PCMPGTB
_mm_cmpgt_epi16 | Greater Than | PCMPGTW
_mm_cmpgt_epi32 | Greater Than | PCMPGTD
_mm_cmplt_epi8 | Less Than | PCMPGTBr
_mm_cmplt_epi16 | Less Than | PCMPGTWr
_mm_cmplt_epi32 | Less Than | PCMPGTDr

## _mm_cmpeq_epi8

__m128i _mm_cmpeq_epi8(__m128i a, __m128i b);

Compares the 16 signed or unsigned 8-bit integers in a and the 16 signed or unsigned 8-bit integers in b for equality.

R0 | R1 | ... | R15
--- | --- | --- | ---
(a0 == b0) ? 0xff : 0x0 | (a1 == b1) ? 0xff : 0x0 | ... | (a15 == b15) ? 0xff : 0x0

## _mm_cmpeq_epi16

__m128i _mm_cmpeq_epi16(__m128i a, __m128i b);

Compares the eight signed or unsigned 16-bit integers in a and the eight signed or unsigned 16-bit integers in b for equality.

R0 | R1 | ... | R7
--- | --- | --- | ---
(a0 == b0) ? 0xffff : 0x0 | (a1 == b1) ? 0xffff : 0x0 | ... | (a7 == b7) ? 0xffff : 0x0

## _mm_cmpeq_epi32

__m128i _mm_cmpeq_epi32(__m128i a, __m128i b);

Compares the four signed or unsigned 32-bit integers in a and the four signed or unsigned 32-bit integers in b for equality.

R0 | R1 | R2 | R3
--- | --- | --- | ---
(a0 == b0) ? 0xffffffff : 0x0 | (a1 == b1) ? 0xffffffff : 0x0 | (a2 == b2) ? 0xffffffff : 0x0 | (a3 == b3) ? 0xffffffff : 0x0

## _mm_cmpgt_epi8

__m128i _mm_cmpgt_epi8(__m128i a, __m128i b);

Compares the 16 signed 8-bit integers in a and the 16 signed 8-bit integers in b for greater than.

R0 | R1 | ... | R15
--- | --- | --- | ---
(a0 > b0) ? 0xff : 0x0 | (a1 > b1) ? 0xff : 0x0 | ... | (a15 > b15) ? 0xff : 0x0

## _mm_cmpgt_epi16

__m128i _mm_cmpgt_epi16(__m128i a, __m128i b);

Compares the eight signed 16-bit integers in a and the eight signed 16-bit integers in b for greater than.

R0 | R1 | ... | R7
--- | --- | --- | ---
(a0 > b0) ? 0xffff : 0x0 | (a1 > b1) ? 0xffff : 0x0 | ... | (a7 > b7) ? 0xffff : 0x0

## _mm_cmpgt_epi32

__m128i _mm_cmpgt_epi32(__m128i a, __m128i b);

Compares the four signed 32-bit integers in a and the four signed 32-bit integers in b for greater than.

R0 | R1 | R2 | R3
--- | --- | --- | ---
(a0 > b0) ? 0xffffffff : 0x0 | (a1 > b1) ? 0xffffffff : 0x0 | (a2 > b2) ? 0xffffffff : 0x0 | (a3 > b3) ? 0xffffffff : 0x0

## _mm_cmplt_epi8

__m128i _mm_cmplt_epi8( __m128i a, __m128i b);

Compares the 16 signed 8-bit integers in a and the 16 signed 8-bit integers in b for less than.

R0 | R1 | ... | R15
--- | --- | --- | ---
(a0 < b0) ? 0xff : 0x0 | (a1 < b1) ? 0xff : 0x0 | ... | (a15 < b15) ? 0xff : 0x0

## _mm_cmplt_epi16

__m128i _mm_cmplt_epi16( __m128i a, __m128i b);

Compares the eight signed 16-bit integers in a and the eight signed 16-bit integers in b for less than.

R0 | R1 | ... | R7
--- | --- | --- | ---
(a0 < b0) ? 0xffff : 0x0 | (a1 < b1) ? 0xffff : 0x0 | ... | (a7 < b7) ? 0xffff : 0x0

## _mm_cmplt_epi32

__m128i _mm_cmplt_epi32( __m128i a, __m128i b);

Compares the four signed 32-bit integers in a and the four signed 32-bit integers in b for less than.

R0 | R1 | R2 | R3
--- | --- | --- | ---
(a0 < b0) ? 0xffffffff : 0x0 | (a1 < b1) ? 0xffffffff : 0x0 | (a2 < b2) ? 0xffffffff : 0x0 | (a3 < b3) ? 0xffffffff : 0x0

Parent topic: Integer Intrinsics