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 pabsd. This instruction returns the absolute value for each packed 32-bit integer of the 128-bit parameter.
__m128i _mm_abs_epi32(
__m128i a
);
Parameters
- [in] a
A 128-bit parameter that contains four 32-bit signed integers for which the absolute values will be returned.
Return value
r0 := (a0 < 0) ? -a0 : a0
r1 := (a1 < 0) ? -a1 : a1
r2 := (a2 < 0) ? -a2 : a2
r3 := (a3 < 0) ? -a3 : a3
Requirements
Intrinsic |
Architecture |
---|---|
_mm_abs_epi32 |
x86, x64 |
Header file <tmmintrin.h>
Remarks
The return value r and parameter a each consist of 128 bits. r0-r3, a0-a3 are the sequentially ordered 32-bit components of these parameters, where r0 and a0 indicate the least significant 32 bits.
Before using this intrinsic, software must ensure that the processor supports the instruction.
Example
#include <stdio.h>
#include <tmmintrin.h>
int main()
{
__m128i a;
a.m128i_i32[0] = 0;
a.m128i_i32[1] = 0;
a.m128i_i32[2] = 2147483647;
a.m128i_i32[3] = -2147483647;
__m128i b = _mm_abs_epi32( a );
printf_s("Original 32 bit pairs:\n0x%08x, 0x%08x\n0x%08x, 0x%08x\n\n",
a.m128i_i32[0], a.m128i_i32[1], a.m128i_i32[2], a.m128i_i32[3]);
printf_s("New 32 bit pairs:\n0x%08x, 0x%08x\n0x%08x, 0x%08x\n",
b.m128i_i32[0], b.m128i_i32[1], b.m128i_i32[2], b.m128i_i32[3]);
return 0;
}
Original 32 bit pairs: 0x00000000, 0x00000000 0x7fffffff, 0x80000001 New 32 bit pairs: 0x00000000, 0x00000000 0x7fffffff, 0x7fffffff