Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Microsoft Specific
Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction pabsw. This instruction returns the absolute value for each packed 16-bit integer of the 128-bit parameter.
__m128i _mm_abs_epi16(
__m128i a
);
Parameters
- [in] a
A 128-bit parameter that contains eight 16-bit signed integers for which the absolute values will be returned.
Return value
r0 := (a0 < 0) ? -a0 : a0
r1 := (a1 < 0) ? -a1 : a1
...
r7 := (a7 < 0) ? -a7 : a7
Requirements
Intrinsic |
Architecture |
---|---|
_mm_abs_epi16 |
x86, x64 |
Header file <tmmintrin.h>
Remarks
The return value r and parameter a each consist of 128 bits. r0-r7, a0-a7 are the sequentially ordered 16-bit components of these parameters, where r0 and a0 indicate the least significant 16 bits.
Before using this intrinsic, software must ensure that the processor supports the instruction.
Example
#include <tmmintrin.h>
#include <stdio.h>
__m128i a;
int main()
{
a.m128i_i16[0] = 0;
a.m128i_i16[1] = 0;
a.m128i_i16[2] = 128;
a.m128i_i16[3] = -128;
a.m128i_i16[4] = 32767;
a.m128i_i16[5] = -32767;
a.m128i_i16[6] = 8756;
a.m128i_i16[7] = -8756;
__m128i b = _mm_abs_epi16( a );
printf_s("Original 16 bit pairs:\n%6d, %6d\n%6d, %6d\n%6d, %6d\n%6d, %6d\n\n",
a.m128i_i16[0], a.m128i_i16[1], a.m128i_i16[2], a.m128i_i16[3],
a.m128i_i16[4], a.m128i_i16[5], a.m128i_i16[6], a.m128i_i16[7]);
printf_s("New 16 bit pairs:\n%6d, %6d\n%6d, %6d\n%6d, %6d\n%6d, %6d\n",
b.m128i_i16[0], b.m128i_i16[1], b.m128i_i16[2], b.m128i_i16[3],
b.m128i_i16[4], b.m128i_i16[5], b.m128i_i16[6], b.m128i_i16[7]);
return 0;
}
Original 16 bit pairs: 0, 0 128, -128 32767, -32767 8756, -8756 New 16 bit pairs: 0, 0 128, 128 32767, 32767 8756, 8756