_mm_hsubs_pi16

Microsoft Specific

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

__m64 _mm_hsubs_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 value 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 := SATURATE_16(a0 - a1)
r1 := SATURATE_16(a2 - a3)
r2 := SATURATE_16(b0 - b1)
r3 := SATURATE_16(b2 - b3)

Requirements

Intrinsic

Architecture

_mm_hsubs_pi16

x86, x64

Header file <tmmintrin.h>

Remarks

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

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 are the least significant 16 bits.

SATURATE_16(x) is defined as ((x > 32767) ? 32767 : ((x < -32768) ? -32768 : x))

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] = 32700;
    b.m64_i16[1] = -1000;
    b.m64_i16[2] = -30000;
    b.m64_i16[3] = 30000;

    __m64 res = _mm_hsubs_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:      32700   -1000  -30000   30000
Result res:          0    8192   32767  -32768

See Also

Concepts

Compiler Intrinsics