Skip to content

Update to current nightly portable_simd #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/simd.rs
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ where

let lo = shifted.cast::<u8>();
let hi = (shifted >> Simd::splat(8)).cast::<u8>();
let decoded_chunks = lo | hi.rotate_lanes_left::<1>();
let decoded_chunks = lo | hi.rotate_elements_left::<1>();

let output = swizzle!(N; decoded_chunks, array!(N; |i| i + i / 3));

@@ -158,7 +158,7 @@ where

// Note that we also need to undo the rotate we did to `hi`.
let lo = data & mask;
let hi = (data & !mask).rotate_lanes_right::<1>();
let hi = (data & !mask).rotate_elements_right::<1>();

// Interleave the shuffled pieces and undo the shift.
let shifted = lo.cast::<u16>() | (hi.cast::<u16>() << Simd::splat(8));
10 changes: 5 additions & 5 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -75,23 +75,23 @@ macro_rules! swizzle {
($N:ident; $x:expr, $index:expr) => {{
use std::simd::*;
struct Swz;
impl<const $N: usize> Swizzle2<$N, $N> for Swz
impl<const $N: usize> Swizzle<$N> for Swz
where
LaneCount<$N>: SupportedLaneCount,
{
const INDEX: [Which; $N] = {
const INDEX: [usize; $N] = {
let index = $index;
array!($N; |i| {
let i = index[i];
if i >= $N {
Which::Second(0)
$N
} else {
Which::First(i)
i
}
})
};
}

Swz::swizzle2($x, Simd::splat(0))
Swz::concat_swizzle($x, Simd::splat(0))
}};
}