Skip to content

Commit

Permalink
fix movemask for i16 avx2 (#139)
Browse files Browse the repository at this point in the history
* fix movemask for i16 avx2

* make test faster

* make movemask test faster on emulators

* skip nightly for MIPS for now
  • Loading branch information
mcroomp authored Sep 26, 2023
1 parent 81cfcab commit 8a915b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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

0 comments on commit 8a915b0

Please sign in to comment.