_mm_sign_epi32
Microsoft Specific
Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction psignd. This instruction negates or clears 32-bit signed integers of a 128-bit parameter.
__m128i _mm_sign_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
The return value can be expressed with the following equations.
r0 := (b0 < 0) ? -a0 : ((b0 == 0) ? 0 : a0)
r1 := (b1 < 0) ? -a1 : ((b1 == 0) ? 0 : a1)
r2 := (b2 < 0) ? -a2 : ((b2 == 0) ? 0 : a2)
r3 := (b3 < 0) ? -a3 : ((b3 == 0) ? 0 : a3)
Requirements
Intrinsic |
Architecture |
---|---|
_mm_sign_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 are the least significant 32 bits.
Before you use this intrinsic, software must ensure that the underlying processor supports the instruction.
Example
#include <stdio.h>
#include <tmmintrin.h>
int main ()
{
__m128i a, b;
a.m128i_i32[0] = 32000;
a.m128i_i32[1] = -6;
a.m128i_i32[2] = 3141259;
a.m128i_i32[3] = -42;
b.m128i_i32[0] = 1;
b.m128i_i32[1] = 0;
b.m128i_i32[2] = -1;
b.m128i_i32[3] = -75000;
__m128i res = _mm_sign_epi32(a, b);
printf_s(" a\t b\t res\n%8d\t%8d\t%8d\n%8d\t%8d\t%8d\n",
a.m128i_i32[0], b.m128i_i32[0], res.m128i_i32[0],
a.m128i_i32[1], b.m128i_i32[1], res.m128i_i32[1]);
printf_s("%8d\t%8d\t%8d\n%8d\t%8d\t%8d\n",
a.m128i_i32[2], b.m128i_i32[2], res.m128i_i32[2],
a.m128i_i32[3], b.m128i_i32[3], res.m128i_i32[3]);
return 0;
}
a b res
32000 1 32000
-6 0 0
3141259 -1 -3141259
-42 -75000 42