_mm_hadd_pd
Visual Studio 2008
Microsoft Specific
Generates the haddpd instruction.
__m128d _mm_hadd_pd( __m128d a, __m128d b, );
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.
// 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]);
}