_mm_hadd_pd

Microsoft Specific

Generates the haddpd instruction.

__m128d _mm_hadd_pd(
   __m128d a,
   __m128d b,
);

Parameters

  • [in] a
    The first operand.

  • [in] b
    The second operand.

Requirements

Intrinsic

Architecture

_mm_hadd_pd

Intel SSE3

Header file <intrin.h>

Remarks

The haddpd instruction performs a horizontal add, meaning that adjacent elements in the same operand are added together. Each 128-bit argument is considered as two 64-bit floating-point elements, numbered from 0 to 1, with 1 being the high-order element. The result of the operation on operand a (A1, A0) and operand b (B1, B0) is (B1 + B0, A1 + A0).

This routine is only available as an intrinsic.

Example

// processor: x86 with SSE3
// Execute the hadd_pd instruction using the intrinsic
// _mm_hadd_pd 

#include <stdio.h>
#include <intrin.h>

#pragma intrinsic ( _mm_hadd_pd )

int main( )
{
    __m128d u, v, w;
    __declspec(align(16)) double a[2] = { 0.1, 0.2 };
    __declspec(align(16)) double b[2] = { 0.001, 0.002 };

    printf_s("Loading double values %e %e into XMM register.\n",
             a[0], a[1] );
    u = _mm_load_pd(a);
    printf_s("Loading double values %e %e into XMM register.\n",
             b[0], b[1] );
    v = _mm_load_pd(b);

    printf_s("Calling _mm_hadd_pd to modify these values.\n");
    w = _mm_hadd_pd ( u , v);

    printf_s("Result: %e %e \n", w.m128d_f64[0], w.m128d_f64[1]);
}
Loading double values 1.000000e-001 2.000000e-001 into XMM register.
Loading double values 1.000000e-003 2.000000e-003 into XMM register.
Calling _mm_hadd_pd to modify these values.
Result: 3.000000e-001 3.000000e-003

See Also

Reference

Compiler Intrinsics