_mm_shuffle_pi8
Microsoft Specific
Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction pshufb. This instruction shuffles 8-byte parameters from a 64-byte parameter.
__m64 _mm_shuffle_pi8(
__m64 a,
__m64 mask
);
Parameters
[in] a
A 64-bit parameter that contains eight 8-bit integers.[in] mask
A 64-bit byte mask.
Return value
The return value can be expressed by the following equations:
r0 := (mask0 & 0x80) ? 0 : SELECT(a, mask0 & 0x07)
r1 := (mask1 & 0x80) ? 0 : SELECT(a, mask1 & 0x07)
...
r7 := (mask7 & 0x80) ? 0 : SELECT(a, mask7 & 0x0f)
Requirements
Intrinsic |
Architecture |
---|---|
_mm_shuffle_pi8 |
x86, x64 |
Header file <tmmintrin.h>
Remarks
r0-r7 and mask0-mask7 are the sequentially ordered 8-bit components of return value r and parameter mask. r0 and mask0 are the least significant 8 bits.
SELECT(a, n) extracts the nth 8-bit parameter from a. The 0th 8-bit parameter is the least significant 8-bits.
mask provides the mapping of bytes from parameter a to bytes in the result. If the byte in mask has its highest bit set, the corresponding byte in the result will be set to zero.
Before you use this intrinsic, software must ensure that the processor supports the instruction.
Example
#include <stdio.h>
#include <tmmintrin.h>
int main ()
{
__m64 a, mask;
a.m64_i8[0] = 1;
a.m64_i8[1] = 2;
a.m64_i8[2] = 4;
a.m64_i8[3] = 8;
a.m64_i8[4] = 16;
a.m64_i8[5] = 32;
a.m64_i8[6] = 64;
a.m64_i8[7] = 127;
mask.m64_u8[0] = 0x87;
mask.m64_u8[1] = 0x06;
mask.m64_u8[2] = 0x85;
mask.m64_u8[3] = 0x04;
mask.m64_u8[4] = 0x83;
mask.m64_u8[5] = 0x02;
mask.m64_u8[6] = 0x81;
mask.m64_u8[7] = 0x00;
__m64 res = _mm_shuffle_pi8(a, mask);
printf_s("Result res:\t%2d\t%2d\t%2d\t%2d\n\t\t%2d\t%2d\t%2d\t%2d\n",
res.m64_i8[0], res.m64_i8[1], res.m64_i8[2],
res.m64_i8[3], res.m64_i8[4], res.m64_i8[5],
res.m64_i8[6], res.m64_i8[7]);
_mm_empty();
return 0;
}
Result res: 0 64 0 16
0 4 0 1