_mm_extract_epi32
Visual Studio 2010
Microsoft Specific
Emits the Streaming SIMD Extensions 4 (SSE4) instruction pextrd. This instruction extracts a 32-bit value from a 128 bit parameter.
int _mm_extract_epi32( __m128i a, const int ndx );
a0 - a3 are the individual 32-bit integers in parameter a, with a0 occupying the lowest 32 bits.
Only the least significant two bits of ndx are used.
The result is the unsigned equivalent of the appropriate 32-bits in parameter a.
Before you use this intrinsic, software must ensure that the processor supports the instruction.
#include <stdio.h>
#include <smmintrin.h>
int main ()
{
__m128i a;
const int ndx1 = 1;
const int ndx2 = 2;
a.m128i_i32[0] = 0;
a.m128i_i32[1] = 65535;
a.m128i_i32[2] = -320000000;
a.m128i_i32[3] = 128;
int res = _mm_extract_epi32(a, ndx1);
printf_s("Result res should equal %d: %d\n", a.m128i_i32[ndx1], res);
res = _mm_extract_epi32(a, ndx2);
printf_s("Result res should equal %d: %d\n", a.m128i_i32[ndx2], res);
return 0;
}
Result res should equal 65535: 65535 Result res should equal -320000000: -320000000