Skip to content
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

fix movemask for i16 avx2 #139

Merged
merged 4 commits into from
Sep 26, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:

strategy:
matrix:
rust: [stable,nightly]
rust: [stable]
features: ["", "std"]

steps:
Expand Down
2 changes: 1 addition & 1 deletion src/i16x16_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl i16x16 {
pub fn move_mask(self) -> i32 {
pick! {
if #[cfg(target_feature="avx2")] {
(move_mask_i8_m256i(pack_i16_to_i8_m256i(self.avx2,shuffle_ai_i64_all_m256i::<0b00_01_10_11>(self.avx2))) & 0xffff) as i32
(move_mask_i8_m256i(pack_i16_to_i8_m256i(self.avx2,shuffle_ai_i64_all_m256i::<0b01_00_11_10>(self.avx2))) & 0xffff) as i32
} else {
self.a.move_mask() | (self.b.move_mask() << 8)
}
Expand Down
13 changes: 13 additions & 0 deletions tests/all_tests/t_i16x16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,21 @@ fn impl_from_i8x16() {

#[test]
fn test_i16x16_move_mask() {
let indexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

for x in 0..256 {
// multiply by prime number to mix bits a bit
let i = x * 251;

let a =
i16x16::from(indexes.map(|x| if i & (1 << x) != 0 { -1 } else { 0 }));

assert_eq!(a.move_mask(), i);
}

let a =
i16x16::from([-1, 0, -2, -3, -1, 0, -2, -3, -1, 0, -1, 0, -1, 0, -1, 0]);

let expected = 0b0101010111011101;
let actual = a.move_mask();
assert_eq!(expected, actual);
Expand Down
Loading