Share via


_mm_extract_epi32

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 
);

Parameters

  • [in] a
    A 128-bit parameter that contains four 32-bit integers. These integers can be signed or unsigned.

  • [in] ndx
    A constant index that specifies the location of the value to extract.

Result value

The return value can be expressed by the following equation:

r := (ndx == 0) ? a0 :
  ((ndx == 1) ? a1 :
  ((ndx == 2) ? a2 : a3))

Requirements

Intrinsic

Architecture

_mm_extract_epi32

x86, x64

Header file <smmintrin.h>

Remarks

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.

Example

#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

See Also

Reference

Compiler Intrinsics