diff --git a/crates/core_simd/src/swizzle_dyn.rs b/crates/core_simd/src/swizzle_dyn.rs index db25783057e..f0253c284e3 100644 --- a/crates/core_simd/src/swizzle_dyn.rs +++ b/crates/core_simd/src/swizzle_dyn.rs @@ -338,7 +338,8 @@ unsafe fn transize( #[allow(unused)] #[inline(always)] fn zeroing_idxs(idxs: Simd) -> Simd { - use crate::simd::{Select, cmp::SimdPartialOrd}; - idxs.simd_lt(Simd::splat(N as u8)) - .select(idxs, Simd::splat(u8::MAX)) + // Adding this sets the high bit for indices N..=127, while PSHUFB ignores + // the other changed bits. The OR preserves the high bit for indices 128..=255. + let zeroing_bits = idxs + Simd::splat((127 - N + 1) as u8); + idxs | zeroing_bits } diff --git a/crates/core_simd/tests/swizzle_dyn.rs b/crates/core_simd/tests/swizzle_dyn.rs index 19ffe1417c8..4ab6c41c074 100644 --- a/crates/core_simd/tests/swizzle_dyn.rs +++ b/crates/core_simd/tests/swizzle_dyn.rs @@ -61,7 +61,7 @@ pub trait SwizzleStrategy { impl SwizzleStrategy for u8 { type Strategy = RangeInclusive; fn swizzled_strategy() -> Self::Strategy { - 0..=64 + 0..=u8::MAX } }