Skip to main content

bitop_avx512

Function bitop_avx512 

Source
pub unsafe fn bitop_avx512<const OP: u8>(lhs: &mut [Block], rhs: &[Block])
Examples found in repository?
crates/competitive/src/data_structure/bitset.rs (line 346)
337    fn bitop_assign<const OP: u8>(&mut self, rhs: &Self) {
338        assert_eq!(
339            self.size, rhs.size,
340            "bitwise operations require equal lengths"
341        );
342        #[cfg(target_arch = "x86_64")]
343        if self.bits.len() >= SIMD_MIN_BLOCKS {
344            if avx512_enabled() && is_x86_feature_detected!("avx512f") {
345                // SAFETY: blocks are 64-byte aligned and feature detection checked AVX-512F.
346                unsafe { simd::bitop_avx512::<OP>(&mut self.bits, &rhs.bits) };
347                return;
348            }
349            if is_x86_feature_detected!("avx2") {
350                // SAFETY: 64-byte alignment also satisfies AVX2 and feature detection checked it.
351                unsafe { simd::bitop_avx2::<OP>(&mut self.bits, &rhs.bits) };
352                return;
353            }
354        }
355        for (lhs, &rhs) in self.words_mut().iter_mut().zip(rhs.words()) {
356            *lhs = match OP {
357                BIT_AND => *lhs & rhs,
358                BIT_OR => *lhs | rhs,
359                BIT_XOR => *lhs ^ rhs,
360                _ => unreachable!(),
361            };
362        }
363    }