Partager via


_mm_hsub_pi16

Microsoft Specific

Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction phsubw. This instruction computes the difference between the elements of two 64-bit parameters.

__m64 _mm_hsub_pi16( 
   __m64 a,
   __m64 b
);

Parameters

  • [in] a
    A 64-bit parameter that contains four 16-bit signed integers.

  • [in] b
    A 64-bit parameter that contains four 16-bit signed integers.

Return value

A 64-bit parameter that contains four 16-bit signed integers. Each integer is the difference between adjacent pairs of elements in the input parameters.

The result can be expressed with the following equations:

r0 := a0 - a1
r1 := a2 - a3
r2 := b0 - b1
r3 := b2 - b3

Requirements

Intrinsic

Architecture

_mm_hsub_pi16

x86, x64

Header file <tmmintrin.h>

Remarks

r0-r3, a0-a3, and b0-b3 are the sequentially ordered 16-bit components of return value r and parameters a and b. r0, a0, and b0 denote the least significant 16 bits.

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

Example

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

int main ()
{
    __m64 a, b;

    a.m64_i16[0] = 32;
    a.m64_i16[1] = 32;
    a.m64_i16[2] = 4096;
    a.m64_i16[3] = -4096;
    b.m64_i16[0] = 16700;
    b.m64_i16[1] = 32000;
    b.m64_i16[2] = -16;
    b.m64_i16[3] = 512;

    __m64 res = _mm_hsub_pi16(a, b);

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

    _mm_empty();

    return 0;
}

Original a:         32      32    4096   -4096
Original b:      16700   32000     -16     512
Result res:          0    8192  -15300    -528

See Also

Concepts

Compiler Intrinsics