Share via


_mm_insert_epi64

Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction pinsrq. This instruction inserts a 64-bit integer into a 128-bit parameter.

__m128i _mm_insert_epi64( 
   __m128i a,
   __int64 b,
   const int ndx 
);

Parameters

  • [in] a
    A 128-bit parameter that contains two 64-bit integers.

  • [in] b
    An integer value.

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

Result value

The result is the same as the input parameter a, except for the value at index ndx. The value at the specified index is replaced with b. This can be expressed with the following equations:

r0 := (ndx == 0) ? b : a0
r1 := (ndx == 1) ? b : a1

Requirements

Intrinsic

Architecture

_mm_insert_epi64

x64

Header file <smmintrin.h>

Remarks

r0 and a0 are the lower 64 bits of return value r and parameter a. r1 and a1 are the higher 64 bits of return value r and parameter a.

Only the least significant bit of ndx is interpreted.

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;
    __int64 b = 4294901750;
    const int ndx = 0;

    a.m128i_i64[0] = 500000;
    a.m128i_i64[1] = 3200000;

    __m128i res = _mm_insert_epi64(a, b, ndx);

    printf_s("Original a:\t%8I64d\t%8I64d\n\n", a.m128i_i64[0], a.m128i_i64[1]);

    printf_s("%I64d should be inserted into index %d.\n", b, ndx);
    printf_s("Result res:\t%8I64d\t%8I64d\n", res.m128i_i64[0], res.m128i_i64[1]);

    return 0;
}
Original a:       500000         3200000

4294901750 should be inserted into index 0.
Result res:     4294901750       3200000

See Also

Reference

Compiler Intrinsics