_mm_hsubw_epi8
Visual Studio 2010 SP1 is required.
Microsoft Specific
Generates the XOP instruction vphsubbw to perform an integer horizontal subtract of its source.
__m128i _mm_hsubw_epi8 (
__m128i src
);
Parameters
- [in] src
A 128-bit parameter that contains sixteen 8-bit signed integers.
Return value
A 128-bit result r that contains eight 16-bit signed integers.
r[i] := src[2*i] - src[2*i+1];
Requirements
Intrinsic |
Architecture |
---|---|
_mm_hsubw_epi8 |
XOP |
Header file <intrin.h>
Remarks
For each of the eight even-odd indexed pairs of 8-bit signed integer values in src, the high-order value is subtracted from the low-order value to produce a 16-bit signed integer result that is stored as the corresponding value in the destination.
The vphsubbw instruction is part of the XOP family of instructions. Before you use this intrinsic, you must ensure that the processor supports this instruction. To determine hardware support for this instruction, call the __cpuid intrinsic with InfoType = 0x80000001 and check bit 11 of CPUInfo[2] (ECX). This bit is 1 when the instruction is supported, and 0 otherwise.
Example
#include <stdio.h>
#include <intrin.h>
int main()
{
__m128i a, d;
int i;
for (i = 0; i < 16; i++) {
a.m128i_i8[i] = ((11*i) % 31) - 16;
}
d = _mm_hsubw_epi8(a);
for (i = 0; i < 16; i++) printf_s(" %3d", a.m128i_i8[i]);
printf_s("\n");
for (i = 0; i < 8; i++) printf_s(" %7d", d.m128i_i16[i]);
printf_s("\n");
}
-16 -5 6 -14 -3 8 -12 -1 10 -10 1 12 -8 3 14 -6 -11 20 -11 -11 20 -11 -11 20