diff --git a/crates/core_simd/src/lane_count.rs b/crates/core_simd/src/lane_count.rs index b017e7d137e308293c8ecd921674d33794565e27..4a5dc80049a9e2cd73b9b78cbd2bab9e4fc14be3 100644 --- a/crates/core_simd/src/lane_count.rs +++ b/crates/core_simd/src/lane_count.rs @@ -15,34 +15,25 @@ impl LaneCount { pub trait SupportedLaneCount: Sealed { #[doc(hidden)] type BitMask: Copy + Default + AsRef<[u8]> + AsMut<[u8]>; - - #[doc(hidden)] - type IntBitMask; } impl Sealed for LaneCount {} impl SupportedLaneCount for LaneCount<1> { type BitMask = [u8; 1]; - type IntBitMask = u8; } impl SupportedLaneCount for LaneCount<2> { type BitMask = [u8; 1]; - type IntBitMask = u8; } impl SupportedLaneCount for LaneCount<4> { type BitMask = [u8; 1]; - type IntBitMask = u8; } impl SupportedLaneCount for LaneCount<8> { type BitMask = [u8; 1]; - type IntBitMask = u8; } impl SupportedLaneCount for LaneCount<16> { type BitMask = [u8; 2]; - type IntBitMask = u16; } impl SupportedLaneCount for LaneCount<32> { type BitMask = [u8; 4]; - type IntBitMask = u32; } diff --git a/crates/core_simd/src/masks/bitmask.rs b/crates/core_simd/src/masks/bitmask.rs index 2689e1a88a8c4b4256d0262244c0b6170489778b..45990e9ce5f97e6caf6e4fe7c3df54ffac5200ba 100644 --- a/crates/core_simd/src/masks/bitmask.rs +++ b/crates/core_simd/src/masks/bitmask.rs @@ -1,3 +1,4 @@ +#![allow(unused_imports)] use super::MaskElement; use crate::simd::intrinsics; use crate::simd::{LaneCount, Simd, SupportedLaneCount}; @@ -101,24 +102,17 @@ pub unsafe fn set_unchecked(&mut self, lane: usize, value: bool) { #[inline] pub fn to_int(self) -> Simd { unsafe { - let mask: as SupportedLaneCount>::IntBitMask = - core::mem::transmute_copy(&self); - intrinsics::simd_select_bitmask(mask, Simd::splat(T::TRUE), Simd::splat(T::FALSE)) + crate::intrinsics::simd_select_bitmask( + self.0, + Simd::splat(T::TRUE), + Simd::splat(T::FALSE), + ) } } #[inline] pub unsafe fn from_int_unchecked(value: Simd) -> Self { - // TODO remove the transmute when rustc is more flexible - assert_eq!( - core::mem::size_of::< as SupportedLaneCount>::BitMask>(), - core::mem::size_of::< as SupportedLaneCount>::IntBitMask>(), - ); - unsafe { - let mask: as SupportedLaneCount>::IntBitMask = - intrinsics::simd_bitmask(value); - Self(core::mem::transmute_copy(&mask), PhantomData) - } + unsafe { Self(crate::intrinsics::simd_bitmask(value), PhantomData) } } #[cfg(feature = "generic_const_exprs")] diff --git a/crates/core_simd/src/masks/full_masks.rs b/crates/core_simd/src/masks/full_masks.rs index dd981cedb932b4c57681caebb9282a012780a375..0f1edf9d2f5eb4c96d5a64936bf9c08ce1443cef 100644 --- a/crates/core_simd/src/masks/full_masks.rs +++ b/crates/core_simd/src/masks/full_masks.rs @@ -106,15 +106,8 @@ pub fn convert(self) -> Mask #[inline] pub fn to_bitmask(self) -> [u8; LaneCount::::BITMASK_LEN] { unsafe { - // TODO remove the transmute when rustc can use arrays of u8 as bitmasks - assert_eq!( - core::mem::size_of::< as SupportedLaneCount>::IntBitMask>(), - LaneCount::::BITMASK_LEN, - ); - let bitmask: as SupportedLaneCount>::IntBitMask = - intrinsics::simd_bitmask(self.0); let mut bitmask: [u8; LaneCount::::BITMASK_LEN] = - core::mem::transmute_copy(&bitmask); + crate::intrinsics::simd_bitmask(self.0); // There is a bug where LLVM appears to implement this operation with the wrong // bit order. @@ -142,15 +135,7 @@ pub fn convert(self) -> Mask } } - // TODO remove the transmute when rustc can use arrays of u8 as bitmasks - assert_eq!( - core::mem::size_of::< as SupportedLaneCount>::IntBitMask>(), - LaneCount::::BITMASK_LEN, - ); - let bitmask: as SupportedLaneCount>::IntBitMask = - core::mem::transmute_copy(&bitmask); - - Self::from_int_unchecked(intrinsics::simd_select_bitmask( + Self::from_int_unchecked(crate::intrinsics::simd_select_bitmask( bitmask, Self::splat(true).to_int(), Self::splat(false).to_int(),