Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions crates/core_simd/src/swizzle_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ unsafe fn transize<T, const N: usize>(
#[allow(unused)]
#[inline(always)]
fn zeroing_idxs<const N: usize>(idxs: Simd<u8, N>) -> Simd<u8, N> {
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
}
2 changes: 1 addition & 1 deletion crates/core_simd/tests/swizzle_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait SwizzleStrategy {
impl SwizzleStrategy for u8 {
type Strategy = RangeInclusive<u8>;
fn swizzled_strategy() -> Self::Strategy {
0..=64
0..=u8::MAX
}
}

Expand Down
Loading