_mm_sign_epi8
Microsoft Specific
Emits the Intel Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction psignb. This instruction negates or clears 8-bit signed integers of a 128-bit parameter.
__m128i _mm_sign_epi8(
__m128i a,
__m128i b
);
Parameters
[in] a
A 128-bit parameter that contains sixteen 8-bit signed integers.[in] b
A 128-bit parameter that contains sixteen 8-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)
...
r15 := (b15 < 0) ? -a15 : ((b15 == 0) ? 0 : a15)
Requirements
Intrinsic |
Architecture |
---|---|
_mm_sign_epi8 |
x86, x64 |
Header file <tmmintrin.h>
Remarks
r0-r15, a0-a15, and b0-b15 are the sequentially ordered 8-bit components of return value r and parameters a and b. r0, a0, and b0 are the least significant 8 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_i8[0] = 25;
a.m128i_i8[1] = 31;
a.m128i_i8[2] = -1;
a.m128i_i8[3] = 10;
a.m128i_i8[4] = -52;
a.m128i_i8[5] = -127;
a.m128i_i8[6] = 127;
a.m128i_i8[7] = 32;
a.m128i_i8[8] = 42;
a.m128i_i8[9] = -15;
a.m128i_i8[10] = -97;
a.m128i_i8[11] = 100;
a.m128i_i8[12] = 125;
a.m128i_i8[13] = 76;
a.m128i_i8[14] = -60;
a.m128i_i8[15] = 1;
b.m128i_i8[0] = 1;
b.m128i_i8[1] = -1;
b.m128i_i8[2] = 0;
b.m128i_i8[3] = 127;
b.m128i_i8[4] = -128;
b.m128i_i8[5] = -42;
b.m128i_i8[6] = 31;
b.m128i_i8[7] = 1;
b.m128i_i8[8] = 0;
b.m128i_i8[9] = 1;
b.m128i_i8[10] = -1;
b.m128i_i8[11] = -1;
b.m128i_i8[12] = 1;
b.m128i_i8[13] = -1;
b.m128i_i8[14] = 1;
b.m128i_i8[15] = 0;
__m128i res = _mm_sign_epi8(a, b);
printf_s(" a\t b\t res\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n",
a.m128i_i8[0], b.m128i_i8[0], res.m128i_i8[0],
a.m128i_i8[1], b.m128i_i8[1], res.m128i_i8[1]);
printf_s("%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n",
a.m128i_i8[2], b.m128i_i8[2], res.m128i_i8[2],
a.m128i_i8[3], b.m128i_i8[3], res.m128i_i8[3],
a.m128i_i8[4], b.m128i_i8[4], res.m128i_i8[4],
a.m128i_i8[5], b.m128i_i8[5], res.m128i_i8[5]);
printf_s("%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n",
a.m128i_i8[6], b.m128i_i8[6], res.m128i_i8[6],
a.m128i_i8[7], b.m128i_i8[7], res.m128i_i8[7],
a.m128i_i8[8], b.m128i_i8[8], res.m128i_i8[8],
a.m128i_i8[9], b.m128i_i8[9], res.m128i_i8[9]);
printf_s("%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n",
a.m128i_i8[10], b.m128i_i8[10], res.m128i_i8[10],
a.m128i_i8[11], b.m128i_i8[11], res.m128i_i8[11],
a.m128i_i8[12], b.m128i_i8[12], res.m128i_i8[12],
a.m128i_i8[13], b.m128i_i8[13], res.m128i_i8[13]);
printf_s("%4d\t%4d\t%4d\n%4d\t%4d\t%4d\n",
a.m128i_i8[14], b.m128i_i8[14], res.m128i_i8[14],
a.m128i_i8[15], b.m128i_i8[15], res.m128i_i8[15]);
return 0;
}
a b res
25 1 25
31 -1 -31
-1 0 0
10 127 10
-52 -128 52
-127 -42 127
127 31 127
32 1 32
42 0 0
-15 1 -15
-97 -1 97
100 -1 -100
125 1 125
76 -1 -76
-60 1 -60
1 0 0