Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Microsoft Specific

Generates the hsubpd instruction.

__m128d _mm_hsub_pd(
   __m128d a,
   __m128d b,


[in] a

The first operand.

[in] b

The second operand.

Intrinsic Architecture


Intel SSE3

Header file <intrin.h>

The hsubpd instruction performs a horizontal subtract, meaning that adjacent elements in the same operand are subtracted. 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 {A0, A1} and operand b {B0, B1} is { A0 - A1, B0 - B1 }.

This routine is only available as an intrinsic.

// processor: x86 with SSE3
// Execute the hsub_pd instruction using the intrinsic
// _mm_hsub_pd 

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

#pragma intrinsic ( _mm_hsub_pd )

int main( )
    __m128d u, v, w;
    __declspec(align(16)) double a[2] = { 0.5, 0.3 };
    __declspec(align(16)) double b[2] = { 0.005, 0.003 };

    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_hsub_pd to modify these values.\n");
    w = _mm_hsub_pd ( u , v);

    printf_s("Result: %e %e \n", w.m128d_f64[0], w.m128d_f64[1]);


Loading double values 5.000000e-001 3.000000e-001 into XMM register.
Loading double values 5.000000e-003 3.000000e-003 into XMM register.
Calling _mm_hsub_pd to modify these values.
Result: 2.000000e-001 2.000000e-003
© 2015 Microsoft