_mm_hadd_pi32

Microsoft Specific

Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction phaddd. This instruction adds the elements of two 64-bit parameters.

__m64 _mm_hadd_pi32( 
   __m64 a,
   __m64 b
);

Parameters

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

  • [in] b
    A 64-bit parameter that contains two 32-bit signed integers.

Return value

A 64-bit value that contains two 64-bit signed integers. Each integer is the sum between adjacent pairs of elements in the input parameters.

The result can be expressed with the following equations:

r0 := a0 + a1
r1 := b0 + b1

Requirements

Intrinsic

Architecture

_mm_hadd_pi32

x86, x64

Header file <tmmintrin.h>

Remarks

r0, a0, and b0 are the lower 32 bits of return value r and of parameters a and b. r1, a1, and b1 are the higher order 32 bits of return value r and of parameters a and b.

Before you use this intrinsic, software must ensure that the underlying processor supports the instruction.

Example

#include <stdio.h>
#include <tmmintrin.h>

int main ()
{
    __m64 a, b;

    a.m64_i32[0] = 65535;
    a.m64_i32[1] = -65536;
    b.m64_i32[0] = 5000;
    b.m64_i32[1] = 32000;

    __m64 res = _mm_hadd_pi32(a, b);

    printf_s("Original a:\t%6d\t%6d\nOriginal b:\t%6d\t%6d\n",
                a.m64_i32[0], a.m64_i32[1], b.m64_i32[0], b.m64_i32[1]);
    printf_s("Result res:\t%6d\t%6d\n",
                res.m64_i32[0], res.m64_i32[1]);

    _mm_empty();
    return 0;
}

Original a:      65535  -65536
Original b:       5000   32000
Result res:         -1   37000

See Also

Concepts

Compiler Intrinsics