_mm_max_epi32
Microsoft Specific
Emits the Streaming SIMD Extensions 4 (SSE4) instruction pmaxsd. This instruction chooses the larger value of the two parameters.
__m128i _mm_max_epi32(
__m128i a,
__m128i b
);
Parameters
[in] a
A 128-bit parameter that contains four 32-bit signed integers.[in] b
A 128-bit parameter that contains four 32-bit signed integers.
Return value
A 128-bit parameter that can be defined with the following equations:
r0 := (a0 > b0) ? a0 : b0
r1 := (a1 > b1) ? a1 : b1
r2 := (a2 > b2) ? a2 : b2
r3 := (a3 > b3) ? a3 : b3
Requirements
Intrinsic |
Architecture |
---|---|
_mm_max_epi32 |
x86, x64 |
Header file <smmintrin.h>
Remarks
r0-r3, a0-a3, and b0-b3 are the sequentially ordered 32-bit components of return value r and parameters a and b. r0, a0, and b0 are the least significant 32 bits.
Before you use this intrinsic, software must ensure that the processor supports the instruction.
Example
#include <stdio.h>
#include <smmintrin.h>
int main ()
{
__m128i a, b;
a.m128i_i32[0] = 0;
a.m128i_i32[1] = 32000;
a.m128i_i32[2] = -750;
a.m128i_i32[3] = 2;
b.m128i_i32[0] = -1000;
b.m128i_i32[1] = -32000;
b.m128i_i32[2] = -500;
b.m128i_i32[3] = 1;
__m128i res = _mm_max_epi32(a, b);
printf_s(" a\t b\t res\n");
printf_s("%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n",
a.m128i_i32[0], b.m128i_i32[0], res.m128i_i32[0],
a.m128i_i32[1], b.m128i_i32[1], res.m128i_i32[1],
a.m128i_i32[2], b.m128i_i32[2], res.m128i_i32[2],
a.m128i_i32[3], b.m128i_i32[3], res.m128i_i32[3]);
return 0;
}
a b res
0 -1000 0
32000 -32000 32000
-750 -500 -500
2 1 2