# Function core::arch::x86_64::_mm256_shuffle_epi32

1.27.0 · source ·

    pub unsafe fn _mm256_shuffle_epi32(a: __m256i, const MASK: i32) -> __m256i

Available on (x86 or x86-64) and target feature `avx2` and x86-64 only.
Expand description

Shuffles 32-bit integers in 128-bit lanes of `a` using the control in `imm8`.

    #[cfg(target_arch = "x86")]
    use std::arch::x86::*;
    #[cfg(target_arch = "x86_64")]
    use std::arch::x86_64::*;

    let a = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);

    let c1 = _mm256_shuffle_epi32(a, 0b00_11_10_01);
    let c2 = _mm256_shuffle_epi32(a, 0b01_00_10_11);

    let expected1 = _mm256_setr_epi32(1, 2, 3, 0, 5, 6, 7, 4);
    let expected2 = _mm256_setr_epi32(3, 2, 0, 1, 7, 6, 4, 5);

    assert_eq!(_mm256_movemask_epi8(_mm256_cmpeq_epi8(c1, expected1)), !0);
    assert_eq!(_mm256_movemask_epi8(_mm256_cmpeq_epi8(c2, expected2)), !0);

Run

Intel’s documentation