Exportar (0) Imprimir
Expandir todo
Expandir Minimizar

_mm_hsub_ps

Microsoft Specific

Generates the hsubps instruction.

__m128 _mm_hsub_ps(
   __m128 a,
   __m128 b,
);

[in] a

The first operand.

[in] b

The second operand.

Intrinsic

Architecture

_mm_hsub_ps

Intel SSE3

Header file <intrin.h>

The hsubps instruction performs a horizontal subtract, meaning that adjacent elements in the same operand are subtracted. Each 128-bit argument is considered as four 32-bit floating point elements, numbered from 0 to 3, with 3 being the high-order element. The result of the operation on operand a { A0, A1, A2, A3 } and operand b {B0, B1, B2, B3 } is { A0-A1, A2-A3, B0-B1, B2-B3 }.

This routine is only available as an intrinsic.

// processor: x86 with SSE3
// Execute the hsub_ps instruction using the intrinsic
// _mm_hsub_ps

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

#pragma intrinsic ( _mm_hsub_ps )

int main( )
{
    __m128 u, v, w;
    __declspec(align(16)) float a[4] = { 0.4, 0.3, 0.2, 0.05 };
    __declspec(align(16)) float b[4] = { 0.004, 0.003, 0.002, 0.0005 };

    printf_s("Loading floating-point values\n"
             "%6.4f %6.4f %6.4f %6.4f into XMM register.\n",
             a[0], a[1], a[2], a[3] );
    u = _mm_load_ps(a);
    printf_s("Loading floating-point values\n"
             "%6.4f %6.4f %6.4f %6.4f into XMM register.\n",
             b[0], b[1], b[2], b[3] );
    v = _mm_load_ps(b);

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

    printf_s("Result: %6.4f %6.4f %6.4f %6.4f\n", w.m128_f32[0],
             w.m128_f32[1], w.m128_f32[2], w.m128_f32[3] );
}
Loading floating-point values
0.4000 0.3000 0.2000 0.0500 into XMM register.
Loading floating-point values 
0.0040 0.0030 0.0020 0.0005 into XMM register.
Calling _mm_hsub_ps to modify these values.
Result: 0.1000 0.1500 0.0010 0.0015

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft