_mm_sign_pi8

Microsoft Specific

Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction psignb. This instruction negates or clears 8-bit signed integers of a 64-bit parameter.

__m64 _mm_sign_pi8( 
   __m64 a,
   __m64 b
);

Parameters

  • [in] a
    A 64-bit parameter that contains eight 8-bit signed integers.

  • [in] b
    A 64-bit parameter that contains eight 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)

...

r7 := (b7 < 0) ? -a7 : ((b7 == 0) ? 0 : a7)

Requirements

Intrinsic

Architecture

_mm_sign_pi8

x86, x64

Header file <tmmintrin.h>

Remarks

r0-r7, a0-a7, and b0-b7 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 ()
{
    __m64 a, b;

    a.m64_i8[0] = 42;
    a.m64_i8[1] = -120;
    a.m64_i8[2] = 51;
    a.m64_i8[3] = 31;
    a.m64_i8[4] = -27;
    a.m64_i8[5] = -15;
    a.m64_i8[6] = -81;
    a.m64_i8[7] = 29;

    b.m64_i8[0] = 1;
    b.m64_i8[1] = 0;
    b.m64_i8[2] = -1;
    b.m64_i8[3] = 127;
    b.m64_i8[4] = -128;
    b.m64_i8[5] = -51;
    b.m64_i8[6] = 0;
    b.m64_i8[7] = 1;

    __m64 res = _mm_sign_pi8(a, b);

    printf_s("     a\t     b\t   res\n%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n",
                a.m64_i8[0], b.m64_i8[0], res.m64_i8[0],
                a.m64_i8[1], b.m64_i8[1], res.m64_i8[1]);
    printf_s("%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n",
                a.m64_i8[2], b.m64_i8[2], res.m64_i8[2],
                a.m64_i8[3], b.m64_i8[3], res.m64_i8[3],
                a.m64_i8[4], b.m64_i8[4], res.m64_i8[4],
                a.m64_i8[5], b.m64_i8[5], res.m64_i8[5]);
    printf_s("%6d\t%6d\t%6d\n%6d\t%6d\t%6d\n",
                a.m64_i8[6], b.m64_i8[6], res.m64_i8[6],
                a.m64_i8[7], b.m64_i8[7], res.m64_i8[7]);

    _mm_empty();

    return 0;
}
     a       b     res
    42       1      42
  -120       0       0
    51      -1     -51
    31     127      31
   -27    -128      27
   -15     -51      15
   -81       0       0
    29       1      29

See Also

Reference

Compiler Intrinsics