Integer Comparison Operations for Streaming SIMD Extensions 2

The comparison intrinsics for Streaming SIMD Extensions 2 (SSE2) and descriptions for each are listed in the following table.

For detailed information about an intrinsic, click on that intrinsic name in the following table.

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.

The prototypes for SSE2 intrinsics are in the emmintrin.h header file.

Intrinsic Name Operation 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

 

__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

 

__m128i _mm_cmpeq_epi16(__m128i a, __m128i b)

Compares the 8 signed or unsigned 16-bit integers in a and the 8 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

 

__m128i _mm_cmpeq_epi32(__m128i a, __m128i b)

Compares the 4 signed or unsigned 32-bit integers in a and the 4 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

 

__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

 

__m128i _mm_cmpgt_epi16(__m128i a, __m128i b)

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

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

 

__m128i _mm_cmpgt_epi32(__m128i a, __m128i b)

Compares the 4 signed 32-bit integers in a and the 4 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

 

__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

 

__m128i _mm_cmplt_epi16( __m128i a, __m128i b)

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

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

 

__m128i _mm_cmplt_epi32( __m128i a, __m128i b)

Compares the 4 signed 32-bit integers in a and the 4 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