Function core::arch::x86::_mm_shuffle_epi8

1.27.0 · source · []
pub unsafe fn _mm_shuffle_epi8(a: __m128i, b: __m128i) -> __m128i
Available on (x86 or x86-64) and target feature ssse3 and x86 only.
Expand description

Shuffles bytes from a according to the content of b.

The last 4 bits of each byte of b are used as addresses into the 16 bytes of a.

In addition, if the highest significant bit of a byte of b is set, the respective destination byte is set to 0.

Picturing a and b as [u8; 16], _mm_shuffle_epi8 is logically equivalent to:

fn mm_shuffle_epi8(a: [u8; 16], b: [u8; 16]) -> [u8; 16] {
    let mut r = [0u8; 16];
    for i in 0..16 {
        // if the most significant bit of b is set,
        // then the destination byte is set to 0.
        if b[i] & 0x80 == 0u8 {
            r[i] = a[(b[i] % 16) as usize];
        }
    }
    r
}
Run

Intel’s documentation

This documentation is an old archive. Please see https://rust.docs.kernel.org instead.