From 159465b272439ec6696787fe62af094bb7d50629 Mon Sep 17 00:00:00 2001 From: Kristof Date: Tue, 26 Sep 2023 15:44:24 +0200 Subject: [PATCH 1/4] fix movemask for i16 avx2 --- src/i16x16_.rs | 2 +- tests/all_tests/t_i16x16.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/i16x16_.rs b/src/i16x16_.rs index 1917b465..510ebef3 100644 --- a/src/i16x16_.rs +++ b/src/i16x16_.rs @@ -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) } diff --git a/tests/all_tests/t_i16x16.rs b/tests/all_tests/t_i16x16.rs index 2354d405..0bb32042 100644 --- a/tests/all_tests/t_i16x16.rs +++ b/tests/all_tests/t_i16x16.rs @@ -586,8 +586,18 @@ 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 i in 0..65535 { + let a = + i16x16::from(indexes.map(|x| if i & (1 << x) != 0 { -1 } else { 0 })); + + assert_eq!(a.move_mask(), i, "a = {}", a); + } + 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); From b31b8161197a4c0a3b3db002f05ba0ef073adca7 Mon Sep 17 00:00:00 2001 From: Kristof Date: Tue, 26 Sep 2023 15:46:08 +0200 Subject: [PATCH 2/4] make test faster --- tests/all_tests/t_i16x16.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/all_tests/t_i16x16.rs b/tests/all_tests/t_i16x16.rs index 0bb32042..8586a885 100644 --- a/tests/all_tests/t_i16x16.rs +++ b/tests/all_tests/t_i16x16.rs @@ -592,7 +592,7 @@ fn test_i16x16_move_mask() { let a = i16x16::from(indexes.map(|x| if i & (1 << x) != 0 { -1 } else { 0 })); - assert_eq!(a.move_mask(), i, "a = {}", a); + assert_eq!(a.move_mask(), i); } let a = From cd354b86ca9b275351f0c26ab5bdf54006004da0 Mon Sep 17 00:00:00 2001 From: Kristof Date: Tue, 26 Sep 2023 15:51:54 +0200 Subject: [PATCH 3/4] make movemask test faster on emulators --- tests/all_tests/t_i16x16.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/all_tests/t_i16x16.rs b/tests/all_tests/t_i16x16.rs index 8586a885..c54a7e2c 100644 --- a/tests/all_tests/t_i16x16.rs +++ b/tests/all_tests/t_i16x16.rs @@ -588,7 +588,10 @@ fn impl_from_i8x16() { fn test_i16x16_move_mask() { let indexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; - for i in 0..65535 { + 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 })); From 6c044015eef445f830db3f0e321218b99db206c3 Mon Sep 17 00:00:00 2001 From: Kristof Date: Tue, 26 Sep 2023 15:53:05 +0200 Subject: [PATCH 4/4] skip nightly for MIPS for now --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a100d320..160f2219 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -75,7 +75,7 @@ jobs: strategy: matrix: - rust: [stable,nightly] + rust: [stable] features: ["", "std"] steps: