_mm_hsub_epi32
Microsoft Specific
Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction phsubd. This instruction computes the difference between the elements of two 128-bit parameters.
__m128i _mm_hsub_epi32(
__m128i a,
__m128i b
);
Parameters
[in] a
A 128-bit parameter that contains four 32-bit signed integers.[in] b
A 128-bit parameter that contains four 32-bit signed integers.
Return value
A 128-bit parameter that contains four 32-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_epi32 |
x86, x64 |
Header file <tmmintrin.h>
Remarks
r0-r3, a0-a3, and b0-b3 are the sequentially ordered 32-bit components of return value r and parameters a and b. r0, a0, and b0 denote the least significant 32 bits.
Before you use this intrinsic, software must ensure that the processor supports the instruction.
Example
#include <stdio.h>
#include <tmmintrin.h>
int main ()
{
__m128i a, b;
a.m128i_i32[0] = 32;
a.m128i_i32[1] = 32;
a.m128i_i32[2] = 4096;
a.m128i_i32[3] = -4096;
b.m128i_i32[0] = 65535;
b.m128i_i32[1] = 32000;
b.m128i_i32[2] = -16;
b.m128i_i32[3] = 512;
__m128i res = _mm_hsub_epi32(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.m128i_i32[0], a.m128i_i32[1], a.m128i_i32[2], a.m128i_i32[3],
b.m128i_i32[0], b.m128i_i32[1], b.m128i_i32[2], b.m128i_i32[3]);
printf_s("Result res:\t%6d\t%6d\t%6d\t%6d\n",
res.m128i_i32[0], res.m128i_i32[1], res.m128i_i32[2], res.m128i_i32[3]);
return 0;
}
Original a: 32 32 4096 -4096 Original b: 65535 32000 -16 512 Result res: 0 8192 33535 -528