diff --git a/fearless_simd/src/generated/avx2.rs b/fearless_simd/src/generated/avx2.rs index 4a0bd797..95e53def 100644 --- a/fearless_simd/src/generated/avx2.rs +++ b/fearless_simd/src/generated/avx2.rs @@ -620,38 +620,6 @@ impl Simd for Avx2 { a * const { f32::to_radians(1.0) } } #[inline(always)] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { crate::kernel!( #[inline(always)] @@ -882,56 +850,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -951,14 +869,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { - self.count_ones_i8x16(self.not_i8x16(a)) - } - #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1040,40 +950,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i8x16, b: i8x16) -> i8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i8x16, b: i8x16) -> i8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i8x16, b: i8x16) -> i8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i8x16(self, a: i8x16) -> i8x16 { - a ^ !0 - } - #[inline(always)] fn shl_i8x16(self, a: i8x16, shift: u32) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1253,14 +1129,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -1495,12 +1363,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) - } - #[inline(always)] fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { crate::kernel!( #[inline(always)] @@ -1530,12 +1392,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { - let (low, high) = self.widening_mul_i8x16(a, b); - let (even, odd) = self.deinterleave_i16x8(low, high); - self.add_i16x8(even, odd) - } - #[inline(always)] fn splat_u8x16(self, val: u8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1765,14 +1621,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { - self.count_ones_u8x16(self.not_u8x16(a)) - } - #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1884,10 +1732,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn not_u8x16(self, a: u8x16) -> u8x16 { - a ^ !0 - } - #[inline(always)] fn shl_u8x16(self, a: u8x16, shift: u32) -> u8x16 { crate::kernel!( #[inline(always)] @@ -2061,14 +1905,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2299,12 +2135,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) - } - #[inline(always)] fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { crate::kernel!( #[inline(always)] @@ -2334,12 +2164,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { - let (low, high) = self.widening_mul_u8x16(a, b); - let (even, odd) = self.deinterleave_u16x8(low, high); - self.add_u16x8(even, odd) - } - #[inline(always)] fn splat_mask8x16(self, val: bool) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2381,20 +2205,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { - mask8x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { - i8x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -2406,82 +2216,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask8x16(self, a: mask8x16) -> mask8x16 { - self.xor_mask8x16(a, self.splat_mask8x16(true)) - } - #[inline(always)] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { - let lanes = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i8x16(lanes); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask8x16( self, a: mask8x16, @@ -2674,10 +2408,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { - self.count_ones_i16x8(self.not_i16x8(a)) - } - #[inline(always)] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8 { let indexes = >::simd_from(self, [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]); @@ -2756,40 +2486,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i16x8, b: i16x8) -> i16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i16x8, b: i16x8) -> i16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i16x8, b: i16x8) -> i16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x8(self, a: i16x8) -> i16x8 { - a ^ !0 - } - #[inline(always)] fn shl_i16x8(self, a: i16x8, shift: u32) -> i16x8 { crate::kernel!( #[inline(always)] @@ -2928,14 +2624,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3350,10 +3038,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { - self.count_ones_u16x8(self.not_u16x8(a)) - } - #[inline(always)] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8 { let indexes = >::simd_from(self, [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]); @@ -3432,40 +3116,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u16x8, b: u16x8) -> u16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u16x8, b: u16x8) -> u16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u16x8, b: u16x8) -> u16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x8(self, a: u16x8) -> u16x8 { - a ^ !0 - } - #[inline(always)] fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8 { crate::kernel!( #[inline(always)] @@ -3604,14 +3254,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3862,12 +3504,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4 { crate::kernel!( #[inline(always)] @@ -3885,12 +3521,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { - let (low, high) = self.widening_mul_u16x8(a, b); - let (even, odd) = self.deinterleave_u32x4(low, high); - self.add_u32x4(even, odd) - } - #[inline(always)] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -3973,20 +3603,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { - mask16x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { - i16x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -3998,87 +3614,11 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x8( + fn select_mask16x8( self, a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask16x8(self, a: mask16x8) -> mask16x8 { - self.xor_mask16x8(a, self.splat_mask16x8(true)) - } - #[inline(always)] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { - let lanes = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i16x8(lanes); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] - fn select_mask16x8( - self, - a: mask16x8, - b: mask16x8, - c: mask16x8, + b: mask16x8, + c: mask16x8, ) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -4280,10 +3820,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { - self.count_ones_i32x4(self.not_i32x4(a)) - } - #[inline(always)] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4 { let indexes = >::simd_from(self, [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); @@ -4382,40 +3918,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i32x4, b: i32x4) -> i32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i32x4, b: i32x4) -> i32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i32x4, b: i32x4) -> i32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x4(self, a: i32x4) -> i32x4 { - a ^ !0 - } - #[inline(always)] fn shl_i32x4(self, a: i32x4, shift: u32) -> i32x4 { crate::kernel!( #[inline(always)] @@ -4535,14 +4037,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -4774,12 +4268,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2 { crate::kernel!( #[inline(always)] @@ -4797,12 +4285,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { - let (low, high) = self.widening_mul_i32x4(a, b); - let (even, odd) = self.deinterleave_i64x2(low, high); - self.add_i64x2(even, odd) - } - #[inline(always)] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8 { crate::kernel!( #[inline(always)] @@ -4938,10 +4420,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { - self.count_ones_u32x4(self.not_u32x4(a)) - } - #[inline(always)] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4 { let indexes = >::simd_from(self, [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); @@ -5025,40 +4503,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u32x4, b: u32x4) -> u32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u32x4, b: u32x4) -> u32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u32x4, b: u32x4) -> u32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x4(self, a: u32x4) -> u32x4 { - a ^ !0 - } - #[inline(always)] fn shl_u32x4(self, a: u32x4, shift: u32) -> u32x4 { crate::kernel!( #[inline(always)] @@ -5178,14 +4622,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -5396,18 +4832,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2 { crate::kernel!( #[inline(always)] @@ -5425,12 +4849,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { - let (low, high) = self.widening_mul_u32x4(a, b); - let (even, odd) = self.deinterleave_u64x2(low, high); - self.add_u64x2(even, odd) - } - #[inline(always)] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8 { crate::kernel!( #[inline(always)] @@ -5529,20 +4947,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { - mask32x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { - i32x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -5554,82 +4958,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask32x4(self, a: mask32x4) -> mask32x4 { - self.xor_mask32x4(a, self.splat_mask32x4(true)) - } - #[inline(always)] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { - let lanes = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i32x4(lanes); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask32x4( self, a: mask32x4, @@ -6206,38 +5534,6 @@ impl Simd for Avx2 { a * const { f64::to_radians(1.0) } } #[inline(always)] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { crate::kernel!( #[inline(always)] @@ -6548,10 +5844,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { - self.count_ones_i64x2(self.not_i64x2(a)) - } - #[inline(always)] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2 { let indexes = >::simd_from(self, [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]); @@ -6656,40 +5948,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i64x2, b: i64x2) -> i64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i64x2, b: i64x2) -> i64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i64x2, b: i64x2) -> i64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x2(self, a: i64x2) -> i64x2 { - a ^ !0 - } - #[inline(always)] fn shl_i64x2(self, a: i64x2, shift: u32) -> i64x2 { crate::kernel!( #[inline(always)] @@ -6815,14 +6073,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7157,10 +6407,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { - self.count_ones_u64x2(self.not_u64x2(a)) - } - #[inline(always)] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2 { let indexes = >::simd_from(self, [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]); @@ -7259,40 +6505,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u64x2, b: u64x2) -> u64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u64x2, b: u64x2) -> u64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u64x2, b: u64x2) -> u64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u64x2(self, a: u64x2) -> u64x2 { - a ^ !0 - } - #[inline(always)] fn shl_u64x2(self, a: u64x2, shift: u32) -> u64x2 { crate::kernel!( #[inline(always)] @@ -7419,14 +6631,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7712,20 +6916,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { - mask64x2 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { - i64x2 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> () { assert!( index < 2usize, @@ -7737,82 +6927,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask64x2(self, a: mask64x2) -> mask64x2 { - self.xor_mask64x2(a, self.splat_mask64x2(true)) - } - #[inline(always)] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { - let lanes = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i64x2(lanes); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask64x2( self, a: mask64x2, @@ -8418,38 +7532,6 @@ impl Simd for Avx2 { a * const { f32::to_radians(1.0) } } #[inline(always)] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f32x8(self, a: mask32x8, b: f32x8, c: f32x8) -> f32x8 { crate::kernel!( #[inline(always)] @@ -8632,56 +7714,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i8x32(self, a: i8x32) -> i8x32 { crate::kernel!( #[inline(always)] @@ -8704,14 +7736,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i8x32(self, a: i8x32) -> i8x32 { - self.count_ones_i8x32(self.not_i8x32(a)) - } - #[inline(always)] - fn swap_bytes_i8x32(self, a: i8x32) -> i8x32 { - a - } - #[inline(always)] fn reverse_bits_i8x32(self, a: i8x32) -> i8x32 { crate::kernel!( #[inline(always)] @@ -8794,40 +7818,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i8x32, b: i8x32) -> i8x32 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i8x32, b: i8x32) -> i8x32 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i8x32, b: i8x32) -> i8x32 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i8x32(self, a: i8x32) -> i8x32 { - a ^ !0 - } - #[inline(always)] fn shl_i8x32(self, a: i8x32, shift: u32) -> i8x32 { crate::kernel!( #[inline(always)] @@ -8960,14 +7950,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x32(self, a: i8x32, b: i8x32, c: i8x32) -> i8x32 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x32(self, a: i8x32, b: i8x32) -> mask8x32 { crate::kernel!( #[inline(always)] @@ -9626,14 +8608,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x32(self, a: u8x32) -> u8x32 { - self.count_ones_u8x32(self.not_u8x32(a)) - } - #[inline(always)] - fn swap_bytes_u8x32(self, a: u8x32) -> u8x32 { - a - } - #[inline(always)] fn reverse_bits_u8x32(self, a: u8x32) -> u8x32 { crate::kernel!( #[inline(always)] @@ -9746,10 +8720,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn not_u8x32(self, a: u8x32) -> u8x32 { - a ^ !0 - } - #[inline(always)] fn shl_u8x32(self, a: u8x32, shift: u32) -> u8x32 { crate::kernel!( #[inline(always)] @@ -9876,14 +8846,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x32(self, a: u8x32, b: u8x32, c: u8x32) -> u8x32 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x32(self, a: u8x32, b: u8x32) -> mask8x32 { crate::kernel!( #[inline(always)] @@ -10168,20 +9130,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { - mask8x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { - i8x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -10193,82 +9141,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask8x32, b: mask8x32) -> mask8x32 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask8x32, b: mask8x32) -> mask8x32 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask8x32, b: mask8x32) -> mask8x32 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask8x32(self, a: mask8x32) -> mask8x32 { - self.xor_mask8x32(a, self.splat_mask8x32(true)) - } - #[inline(always)] - fn reverse_mask8x32(self, a: mask8x32) -> mask8x32 { - let lanes = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i8x32(lanes); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask8x32( self, a: mask8x32, @@ -10438,56 +9310,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i16x16(self, a: i16x16) -> i16x16 { crate::kernel!( #[inline(always)] @@ -10510,10 +9332,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x16(self, a: i16x16) -> i16x16 { - self.count_ones_i16x16(self.not_i16x16(a)) - } - #[inline(always)] fn swap_bytes_i16x16(self, a: i16x16) -> i16x16 { let indexes = >::simd_from( self, @@ -10598,48 +9416,14 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i16x16, b: i16x16) -> i16x16 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i16x16, b: i16x16) -> i16x16 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { + fn shl_i16x16(self, a: i16x16, shift: u32) -> i16x16 { crate::kernel!( #[inline(always)] - fn kernel(token: Avx2, a: i16x16, b: i16x16) -> i16x16 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) + fn kernel(token: Avx2, a: i16x16, shift: u32) -> i16x16 { + _mm256_sll_epi16(a.into(), _mm_cvtsi32_si128(shift.cast_signed())).simd_into(token) } ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x16(self, a: i16x16) -> i16x16 { - a ^ !0 - } - #[inline(always)] - fn shl_i16x16(self, a: i16x16, shift: u32) -> i16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i16x16, shift: u32) -> i16x16 { - _mm256_sll_epi16(a.into(), _mm_cvtsi32_si128(shift.cast_signed())).simd_into(token) - } - ); - kernel(self, a, shift) + kernel(self, a, shift) } #[inline(always)] fn shlv_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { @@ -10716,14 +9500,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x16(self, a: i16x16, b: i16x16, c: i16x16) -> i16x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x16(self, a: i16x16, b: i16x16) -> mask16x16 { crate::kernel!( #[inline(always)] @@ -11086,56 +9862,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u16x16(self, a: u16x16) -> u16x16 { crate::kernel!( #[inline(always)] @@ -11158,10 +9884,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x16(self, a: u16x16) -> u16x16 { - self.count_ones_u16x16(self.not_u16x16(a)) - } - #[inline(always)] fn swap_bytes_u16x16(self, a: u16x16) -> u16x16 { let indexes = >::simd_from( self, @@ -11246,40 +9968,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u16x16, b: u16x16) -> u16x16 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u16x16, b: u16x16) -> u16x16 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u16x16, b: u16x16) -> u16x16 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x16(self, a: u16x16) -> u16x16 { - a ^ !0 - } - #[inline(always)] fn shl_u16x16(self, a: u16x16, shift: u32) -> u16x16 { crate::kernel!( #[inline(always)] @@ -11364,14 +10052,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x16(self, a: u16x16, b: u16x16, c: u16x16) -> u16x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x16(self, a: u16x16, b: u16x16) -> mask16x16 { crate::kernel!( #[inline(always)] @@ -11718,20 +10398,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { - mask16x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { - i16x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -11743,82 +10409,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask16x16, b: mask16x16) -> mask16x16 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask16x16, b: mask16x16) -> mask16x16 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask16x16, b: mask16x16) -> mask16x16 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask16x16(self, a: mask16x16) -> mask16x16 { - self.xor_mask16x16(a, self.splat_mask16x16(true)) - } - #[inline(always)] - fn reverse_mask16x16(self, a: mask16x16) -> mask16x16 { - let lanes = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i16x16(lanes); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask16x16( self, a: mask16x16, @@ -12109,10 +10699,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x8(self, a: i32x8) -> i32x8 { - self.count_ones_i32x8(self.not_i32x8(a)) - } - #[inline(always)] fn swap_bytes_i32x8(self, a: i32x8) -> i32x8 { let indexes = >::simd_from( self, @@ -12219,40 +10805,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i32x8, b: i32x8) -> i32x8 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i32x8, b: i32x8) -> i32x8 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i32x8, b: i32x8) -> i32x8 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x8(self, a: i32x8) -> i32x8 { - a ^ !0 - } - #[inline(always)] fn shl_i32x8(self, a: i32x8, shift: u32) -> i32x8 { crate::kernel!( #[inline(always)] @@ -12313,14 +10865,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x8(self, a: i32x8, b: i32x8, c: i32x8) -> i32x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x8(self, a: i32x8, b: i32x8) -> mask32x8 { crate::kernel!( #[inline(always)] @@ -12770,10 +11314,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x8(self, a: u32x8) -> u32x8 { - self.count_ones_u32x8(self.not_u32x8(a)) - } - #[inline(always)] fn swap_bytes_u32x8(self, a: u32x8) -> u32x8 { let indexes = >::simd_from( self, @@ -12863,40 +11403,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u32x8, b: u32x8) -> u32x8 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u32x8, b: u32x8) -> u32x8 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u32x8, b: u32x8) -> u32x8 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x8(self, a: u32x8) -> u32x8 { - a ^ !0 - } - #[inline(always)] fn shl_u32x8(self, a: u32x8, shift: u32) -> u32x8 { crate::kernel!( #[inline(always)] @@ -12957,14 +11463,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x8(self, a: u32x8, b: u32x8, c: u32x8) -> u32x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x8(self, a: u32x8, b: u32x8) -> mask32x8 { crate::kernel!( #[inline(always)] @@ -13290,20 +11788,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { - mask32x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { - i32x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -13315,82 +11799,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask32x8, b: mask32x8) -> mask32x8 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask32x8, b: mask32x8) -> mask32x8 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask32x8, b: mask32x8) -> mask32x8 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask32x8(self, a: mask32x8) -> mask32x8 { - self.xor_mask32x8(a, self.splat_mask32x8(true)) - } - #[inline(always)] - fn reverse_mask32x8(self, a: mask32x8) -> mask32x8 { - let lanes = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i32x8(lanes); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask32x8( self, a: mask32x8, @@ -14005,38 +12413,6 @@ impl Simd for Avx2 { a * const { f64::to_radians(1.0) } } #[inline(always)] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f64x4(self, a: mask64x4, b: f64x4, c: f64x4) -> f64x4 { crate::kernel!( #[inline(always)] @@ -14376,10 +12752,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x4(self, a: i64x4) -> i64x4 { - self.count_ones_i64x4(self.not_i64x4(a)) - } - #[inline(always)] fn swap_bytes_i64x4(self, a: i64x4) -> i64x4 { let indexes = >::simd_from( self, @@ -14493,40 +12865,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn and_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i64x4, b: i64x4) -> i64x4 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i64x4, b: i64x4) -> i64x4 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: i64x4, b: i64x4) -> i64x4 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x4(self, a: i64x4) -> i64x4 { - a ^ !0 - } - #[inline(always)] fn shl_i64x4(self, a: i64x4, shift: u32) -> i64x4 { crate::kernel!( #[inline(always)] @@ -14614,14 +12952,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i64x4(self, a: i64x4, b: i64x4, c: i64x4) -> i64x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x4(self, a: i64x4, b: i64x4) -> mask64x4 { crate::kernel!( #[inline(always)] @@ -15005,10 +13335,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x4(self, a: u64x4) -> u64x4 { - self.count_ones_u64x4(self.not_u64x4(a)) - } - #[inline(always)] fn swap_bytes_u64x4(self, a: u64x4) -> u64x4 { let indexes = >::simd_from( self, @@ -15110,46 +13436,12 @@ impl Simd for Avx2 { let cross = _mm256_add_epi64(_mm256_mul_epu32(a_high, b), _mm256_mul_epu32(a, b_high)); let low = _mm256_mul_epu32(a, b); - _mm256_add_epi64(low, _mm256_slli_epi64::<32>(cross)).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn and_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u64x4, b: u64x4) -> u64x4 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u64x4, b: u64x4) -> u64x4 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: u64x4, b: u64x4) -> u64x4 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) + _mm256_add_epi64(low, _mm256_slli_epi64::<32>(cross)).simd_into(token) } ); kernel(self, a, b) } #[inline(always)] - fn not_u64x4(self, a: u64x4) -> u64x4 { - a ^ !0 - } - #[inline(always)] fn shl_u64x4(self, a: u64x4, shift: u32) -> u64x4 { crate::kernel!( #[inline(always)] @@ -15236,14 +13528,6 @@ impl Simd for Avx2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u64x4(self, a: u64x4, b: u64x4, c: u64x4) -> u64x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x4(self, a: u64x4, b: u64x4) -> mask64x4 { crate::kernel!( #[inline(always)] @@ -15503,20 +13787,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { - mask64x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { - i64x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -15528,82 +13798,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask64x4, b: mask64x4) -> mask64x4 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask64x4, b: mask64x4) -> mask64x4 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx2, a: mask64x4, b: mask64x4) -> mask64x4 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask64x4(self, a: mask64x4) -> mask64x4 { - self.xor_mask64x4(a, self.splat_mask64x4(true)) - } - #[inline(always)] - fn reverse_mask64x4(self, a: mask64x4) -> mask64x4 { - let lanes = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i64x4(lanes); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask64x4( self, a: mask64x4, @@ -15871,38 +14065,6 @@ impl Simd for Avx2 { self.combine_mask32x8(self.simd_ne_f32x8(a0, b0), self.simd_ne_f32x8(a1, b1)) } #[inline(always)] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f32x16(self, a: f32x16) -> (f32x8, f32x8) { ( f32x8 { @@ -15932,56 +14094,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i8x64(self, a: i8x64) -> (i8x32, i8x32) { ( i8x32 { @@ -16677,20 +14789,6 @@ impl Simd for Avx2 { kernel(self, bits) } #[inline(always)] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { - mask8x64 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { - i8x64 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> () { assert!( index < 64usize, @@ -16702,36 +14800,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask8x64(self, a: mask8x64) -> (mask8x32, mask8x32) { ( mask8x32 { @@ -16761,56 +14829,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i16x32(self, a: i16x32) -> (i16x16, i16x16) { ( i16x16 { @@ -16840,56 +14858,6 @@ impl Simd for Avx2 { }) } #[inline(always)] - fn compress_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u16x32(self, a: u16x32) -> (u16x16, u16x16) { ( u16x16 { @@ -16919,20 +14887,6 @@ impl Simd for Avx2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { - mask16x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { - i16x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -16944,36 +14898,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask16x32(self, a: mask16x32) -> (mask16x16, mask16x16) { ( mask16x16 { @@ -17354,20 +15278,6 @@ impl Simd for Avx2 { kernel(self, bits) } #[inline(always)] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { - mask32x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { - i32x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -17379,36 +15289,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask32x16(self, a: mask32x16) -> (mask32x8, mask32x8) { ( mask32x8 { @@ -17585,38 +15465,6 @@ impl Simd for Avx2 { self.combine_mask64x4(self.simd_ne_f64x4(a0, b0), self.simd_ne_f64x4(a1, b1)) } #[inline(always)] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f64x8(self, a: f64x8) -> (f64x4, f64x4) { ( f64x4 { @@ -17995,20 +15843,6 @@ impl Simd for Avx2 { kernel(self, bits) } #[inline(always)] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { - mask64x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { - i64x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -18020,36 +15854,6 @@ impl Simd for Avx2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask64x8(self, a: mask64x8) -> (mask64x4, mask64x4) { ( mask64x4 { diff --git a/fearless_simd/src/generated/avx512.rs b/fearless_simd/src/generated/avx512.rs index 5a880cf3..8769bb71 100644 --- a/fearless_simd/src/generated/avx512.rs +++ b/fearless_simd/src/generated/avx512.rs @@ -1272,14 +1272,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { - self.count_ones_i8x16(self.not_i8x16(a)) - } - #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1355,40 +1347,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x16, b: i8x16) -> i8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x16, b: i8x16) -> i8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x16, b: i8x16) -> i8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i8x16(self, a: i8x16) -> i8x16 { - a ^ !0 - } - #[inline(always)] fn shl_i8x16(self, a: i8x16, shift: u32) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1560,14 +1518,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -1814,12 +1764,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) - } - #[inline(always)] fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { crate::kernel!( #[inline(always)] @@ -1853,12 +1797,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { - let (low, high) = self.widening_mul_i8x16(a, b); - let (even, odd) = self.deinterleave_i16x8(low, high); - self.add_i16x8(even, odd) - } - #[inline(always)] fn splat_u8x16(self, val: u8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -2076,14 +2014,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { - self.count_ones_u8x16(self.not_u8x16(a)) - } - #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { crate::kernel!( #[inline(always)] @@ -2189,10 +2119,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn not_u8x16(self, a: u8x16) -> u8x16 { - a ^ !0 - } - #[inline(always)] fn shl_u8x16(self, a: u8x16, shift: u32) -> u8x16 { crate::kernel!( #[inline(always)] @@ -2361,14 +2287,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2605,12 +2523,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) - } - #[inline(always)] fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { crate::kernel!( #[inline(always)] @@ -2644,12 +2556,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { - let (low, high) = self.widening_mul_u8x16(a, b); - let (even, odd) = self.deinterleave_u16x8(low, high); - self.add_u16x8(even, odd) - } - #[inline(always)] fn splat_mask8x16(self, val: bool) -> mask8x16 { mask8x16 { val: (if val { 65535u64 } else { 0 }) as _, @@ -2951,10 +2857,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { - self.count_ones_i16x8(self.not_i16x8(a)) - } - #[inline(always)] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8 { let indexes = >::simd_from(self, [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]); @@ -3027,40 +2929,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x8, b: i16x8) -> i16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x8, b: i16x8) -> i16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x8, b: i16x8) -> i16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x8(self, a: i16x8) -> i16x8 { - a ^ !0 - } - #[inline(always)] fn shl_i16x8(self, a: i16x8, shift: u32) -> i16x8 { crate::kernel!( #[inline(always)] @@ -3191,14 +3059,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3642,10 +3502,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { - self.count_ones_u16x8(self.not_u16x8(a)) - } - #[inline(always)] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8 { let indexes = >::simd_from(self, [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]); @@ -3718,40 +3574,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x8, b: u16x8) -> u16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x8, b: u16x8) -> u16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x8, b: u16x8) -> u16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x8(self, a: u16x8) -> u16x8 { - a ^ !0 - } - #[inline(always)] fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8 { crate::kernel!( #[inline(always)] @@ -3882,14 +3704,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -4134,12 +3948,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4 { crate::kernel!( #[inline(always)] @@ -4157,12 +3965,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { - let (low, high) = self.widening_mul_u16x8(a, b); - let (even, odd) = self.deinterleave_u32x4(low, high); - self.add_u32x4(even, odd) - } - #[inline(always)] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -4516,10 +4318,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { - self.count_ones_i32x4(self.not_i32x4(a)) - } - #[inline(always)] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4 { let indexes = >::simd_from(self, [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); @@ -4604,40 +4402,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x4, b: i32x4) -> i32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x4, b: i32x4) -> i32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x4, b: i32x4) -> i32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x4(self, a: i32x4) -> i32x4 { - a ^ !0 - } - #[inline(always)] fn shl_i32x4(self, a: i32x4, shift: u32) -> i32x4 { crate::kernel!( #[inline(always)] @@ -4757,14 +4521,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -4983,18 +4739,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn widening_mul_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.mul_i64x2(a0, b0), self.mul_i64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2 { crate::kernel!( #[inline(always)] @@ -5012,12 +4756,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { - let (low, high) = self.widening_mul_i32x4(a, b); - let (even, odd) = self.deinterleave_i64x2(low, high); - self.add_i64x2(even, odd) - } - #[inline(always)] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8 { crate::kernel!( #[inline(always)] @@ -5174,10 +4912,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { - self.count_ones_u32x4(self.not_u32x4(a)) - } - #[inline(always)] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4 { let indexes = >::simd_from(self, [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); @@ -5255,40 +4989,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x4, b: u32x4) -> u32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x4, b: u32x4) -> u32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x4, b: u32x4) -> u32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x4(self, a: u32x4) -> u32x4 { - a ^ !0 - } - #[inline(always)] fn shl_u32x4(self, a: u32x4, shift: u32) -> u32x4 { crate::kernel!( #[inline(always)] @@ -5408,14 +5108,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -5624,18 +5316,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2 { crate::kernel!( #[inline(always)] @@ -5653,12 +5333,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { - let (low, high) = self.widening_mul_u32x4(a, b); - let (even, odd) = self.deinterleave_u64x2(low, high); - self.add_u64x2(even, odd) - } - #[inline(always)] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8 { crate::kernel!( #[inline(always)] @@ -6778,10 +6452,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { - self.count_ones_i64x2(self.not_i64x2(a)) - } - #[inline(always)] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2 { let indexes = >::simd_from(self, [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]); @@ -6866,40 +6536,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x2, b: i64x2) -> i64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x2, b: i64x2) -> i64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x2, b: i64x2) -> i64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x2(self, a: i64x2) -> i64x2 { - a ^ !0 - } - #[inline(always)] fn shl_i64x2(self, a: i64x2, shift: u32) -> i64x2 { crate::kernel!( #[inline(always)] @@ -7000,14 +6636,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7364,10 +6992,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { - self.count_ones_u64x2(self.not_u64x2(a)) - } - #[inline(always)] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2 { let indexes = >::simd_from(self, [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]); @@ -7445,40 +7069,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x2, b: u64x2) -> u64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x2, b: u64x2) -> u64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x2, b: u64x2) -> u64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u64x2(self, a: u64x2) -> u64x2 { - a ^ !0 - } - #[inline(always)] fn shl_u64x2(self, a: u64x2, shift: u32) -> u64x2 { crate::kernel!( #[inline(always)] @@ -7579,14 +7169,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -8909,14 +8491,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i8x32(self, a: i8x32) -> i8x32 { - self.count_ones_i8x32(self.not_i8x32(a)) - } - #[inline(always)] - fn swap_bytes_i8x32(self, a: i8x32) -> i8x32 { - a - } - #[inline(always)] fn reverse_bits_i8x32(self, a: i8x32) -> i8x32 { crate::kernel!( #[inline(always)] @@ -8943,89 +8517,55 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn saturating_add_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - _mm256_adds_epi8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn sub_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - _mm256_sub_epi8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn saturating_sub_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - _mm256_subs_epi8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn mul_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - let a = a.into(); - let b = b.into(); - let low_mask = _mm256_set1_epi16(0xFF); - let dst_even = _mm256_mullo_epi16(a, b); - let dst_odd = _mm256_maddubs_epi16(a, _mm256_andnot_si256(low_mask, b)); - _mm256_or_si256( - _mm256_slli_epi16(dst_odd, 8), - _mm256_and_si256(dst_even, low_mask), - ) - .simd_into(token) + fn saturating_add_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { + crate::kernel!( + #[inline(always)] + fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { + _mm256_adds_epi8(a.into(), b.into()).simd_into(token) } ); kernel(self, a, b) } #[inline(always)] - fn and_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { + fn sub_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { crate::kernel!( #[inline(always)] fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) + _mm256_sub_epi8(a.into(), b.into()).simd_into(token) } ); kernel(self, a, b) } #[inline(always)] - fn or_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { + fn saturating_sub_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { crate::kernel!( #[inline(always)] fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) + _mm256_subs_epi8(a.into(), b.into()).simd_into(token) } ); kernel(self, a, b) } #[inline(always)] - fn xor_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { + fn mul_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { crate::kernel!( #[inline(always)] fn kernel(token: Avx512, a: i8x32, b: i8x32) -> i8x32 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) + let a = a.into(); + let b = b.into(); + let low_mask = _mm256_set1_epi16(0xFF); + let dst_even = _mm256_mullo_epi16(a, b); + let dst_odd = _mm256_maddubs_epi16(a, _mm256_andnot_si256(low_mask, b)); + _mm256_or_si256( + _mm256_slli_epi16(dst_odd, 8), + _mm256_and_si256(dst_even, low_mask), + ) + .simd_into(token) } ); kernel(self, a, b) } #[inline(always)] - fn not_i8x32(self, a: i8x32) -> i8x32 { - a ^ !0 - } - #[inline(always)] fn shl_i8x32(self, a: i8x32, shift: u32) -> i8x32 { crate::kernel!( #[inline(always)] @@ -9120,14 +8660,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x32(self, a: i8x32, b: i8x32, c: i8x32) -> i8x32 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x32(self, a: i8x32, b: i8x32) -> mask8x32 { crate::kernel!( #[inline(always)] @@ -9691,14 +9223,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x32(self, a: u8x32) -> u8x32 { - self.count_ones_u8x32(self.not_u8x32(a)) - } - #[inline(always)] - fn swap_bytes_u8x32(self, a: u8x32) -> u8x32 { - a - } - #[inline(always)] fn reverse_bits_u8x32(self, a: u8x32) -> u8x32 { crate::kernel!( #[inline(always)] @@ -9804,10 +9328,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn not_u8x32(self, a: u8x32) -> u8x32 { - a ^ !0 - } - #[inline(always)] fn shl_u8x32(self, a: u8x32, shift: u32) -> u8x32 { crate::kernel!( #[inline(always)] @@ -9899,14 +9419,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x32(self, a: u8x32, b: u8x32, c: u8x32) -> u8x32 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x32(self, a: u8x32, b: u8x32) -> mask8x32 { crate::kernel!( #[inline(always)] @@ -10562,10 +10074,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x16(self, a: i16x16) -> i16x16 { - self.count_ones_i16x16(self.not_i16x16(a)) - } - #[inline(always)] fn swap_bytes_i16x16(self, a: i16x16) -> i16x16 { let indexes = >::simd_from( self, @@ -10643,40 +10151,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x16, b: i16x16) -> i16x16 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x16, b: i16x16) -> i16x16 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x16, b: i16x16) -> i16x16 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x16(self, a: i16x16) -> i16x16 { - a ^ !0 - } - #[inline(always)] fn shl_i16x16(self, a: i16x16, shift: u32) -> i16x16 { crate::kernel!( #[inline(always)] @@ -10737,14 +10211,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x16(self, a: i16x16, b: i16x16, c: i16x16) -> i16x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x16(self, a: i16x16, b: i16x16) -> mask16x16 { crate::kernel!( #[inline(always)] @@ -11246,10 +10712,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x16(self, a: u16x16) -> u16x16 { - self.count_ones_u16x16(self.not_u16x16(a)) - } - #[inline(always)] fn swap_bytes_u16x16(self, a: u16x16) -> u16x16 { let indexes = >::simd_from( self, @@ -11327,40 +10789,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x16, b: u16x16) -> u16x16 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x16, b: u16x16) -> u16x16 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x16, b: u16x16) -> u16x16 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x16(self, a: u16x16) -> u16x16 { - a ^ !0 - } - #[inline(always)] fn shl_u16x16(self, a: u16x16, shift: u32) -> u16x16 { crate::kernel!( #[inline(always)] @@ -11421,14 +10849,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x16(self, a: u16x16, b: u16x16, c: u16x16) -> u16x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x16(self, a: u16x16, b: u16x16) -> mask16x16 { crate::kernel!( #[inline(always)] @@ -12122,10 +11542,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x8(self, a: i32x8) -> i32x8 { - self.count_ones_i32x8(self.not_i32x8(a)) - } - #[inline(always)] fn swap_bytes_i32x8(self, a: i32x8) -> i32x8 { let indexes = >::simd_from( self, @@ -12219,40 +11635,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x8, b: i32x8) -> i32x8 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x8, b: i32x8) -> i32x8 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x8, b: i32x8) -> i32x8 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x8(self, a: i32x8) -> i32x8 { - a ^ !0 - } - #[inline(always)] fn shl_i32x8(self, a: i32x8, shift: u32) -> i32x8 { crate::kernel!( #[inline(always)] @@ -12313,14 +11695,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x8(self, a: i32x8, b: i32x8, c: i32x8) -> i32x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x8(self, a: i32x8, b: i32x8) -> mask32x8 { crate::kernel!( #[inline(always)] @@ -12770,10 +12144,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x8(self, a: u32x8) -> u32x8 { - self.count_ones_u32x8(self.not_u32x8(a)) - } - #[inline(always)] fn swap_bytes_u32x8(self, a: u32x8) -> u32x8 { let indexes = >::simd_from( self, @@ -12856,40 +12226,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x8, b: u32x8) -> u32x8 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x8, b: u32x8) -> u32x8 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x8, b: u32x8) -> u32x8 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x8(self, a: u32x8) -> u32x8 { - a ^ !0 - } - #[inline(always)] fn shl_u32x8(self, a: u32x8, shift: u32) -> u32x8 { crate::kernel!( #[inline(always)] @@ -12950,14 +12286,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x8(self, a: u32x8, b: u32x8, c: u32x8) -> u32x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x8(self, a: u32x8, b: u32x8) -> mask32x8 { crate::kernel!( #[inline(always)] @@ -14336,10 +13664,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x4(self, a: i64x4) -> i64x4 { - self.count_ones_i64x4(self.not_i64x4(a)) - } - #[inline(always)] fn swap_bytes_i64x4(self, a: i64x4) -> i64x4 { let indexes = >::simd_from( self, @@ -14433,40 +13757,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x4, b: i64x4) -> i64x4 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x4, b: i64x4) -> i64x4 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x4, b: i64x4) -> i64x4 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x4(self, a: i64x4) -> i64x4 { - a ^ !0 - } - #[inline(always)] fn shl_i64x4(self, a: i64x4, shift: u32) -> i64x4 { crate::kernel!( #[inline(always)] @@ -14527,14 +13817,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i64x4(self, a: i64x4, b: i64x4, c: i64x4) -> i64x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x4(self, a: i64x4, b: i64x4) -> mask64x4 { crate::kernel!( #[inline(always)] @@ -14920,10 +14202,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x4(self, a: u64x4) -> u64x4 { - self.count_ones_u64x4(self.not_u64x4(a)) - } - #[inline(always)] fn swap_bytes_u64x4(self, a: u64x4) -> u64x4 { let indexes = >::simd_from( self, @@ -15006,40 +14284,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x4, b: u64x4) -> u64x4 { - _mm256_and_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x4, b: u64x4) -> u64x4 { - _mm256_or_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x4, b: u64x4) -> u64x4 { - _mm256_xor_si256(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u64x4(self, a: u64x4) -> u64x4 { - a ^ !0 - } - #[inline(always)] fn shl_u64x4(self, a: u64x4, shift: u32) -> u64x4 { crate::kernel!( #[inline(always)] @@ -15100,14 +14344,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u64x4(self, a: u64x4, b: u64x4, c: u64x4) -> u64x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x4(self, a: u64x4, b: u64x4) -> mask64x4 { crate::kernel!( #[inline(always)] @@ -16454,17 +15690,9 @@ impl Simd for Avx512 { #[inline(always)] fn kernel(token: Avx512, a: i8x64) -> i8x64 { _mm512_popcnt_epi8(a.into()).simd_into(token) - } - ); - kernel(self, a) - } - #[inline(always)] - fn count_zeros_i8x64(self, a: i8x64) -> i8x64 { - self.count_ones_i8x64(self.not_i8x64(a)) - } - #[inline(always)] - fn swap_bytes_i8x64(self, a: i8x64) -> i8x64 { - a + } + ); + kernel(self, a) } #[inline(always)] fn reverse_bits_i8x64(self, a: i8x64) -> i8x64 { @@ -16542,40 +15770,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i8x64(self, a: i8x64, b: i8x64) -> i8x64 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x64, b: i8x64) -> i8x64 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x64(self, a: i8x64, b: i8x64) -> i8x64 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x64, b: i8x64) -> i8x64 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x64(self, a: i8x64, b: i8x64) -> i8x64 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i8x64, b: i8x64) -> i8x64 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i8x64(self, a: i8x64) -> i8x64 { - a ^ !0 - } - #[inline(always)] fn shl_i8x64(self, a: i8x64, shift: u32) -> i8x64 { crate::kernel!( #[inline(always)] @@ -16672,14 +15866,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x64(self, a: i8x64, b: i8x64, c: i8x64) -> i8x64 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x64(self, a: i8x64, b: i8x64) -> mask8x64 { crate::kernel!( #[inline(always)] @@ -17230,14 +16416,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x64(self, a: u8x64) -> u8x64 { - self.count_ones_u8x64(self.not_u8x64(a)) - } - #[inline(always)] - fn swap_bytes_u8x64(self, a: u8x64) -> u8x64 { - a - } - #[inline(always)] fn reverse_bits_u8x64(self, a: u8x64) -> u8x64 { crate::kernel!( #[inline(always)] @@ -17343,10 +16521,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn not_u8x64(self, a: u8x64) -> u8x64 { - a ^ !0 - } - #[inline(always)] fn shl_u8x64(self, a: u8x64, shift: u32) -> u8x64 { crate::kernel!( #[inline(always)] @@ -17439,14 +16613,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x64(self, a: u8x64, b: u8x64, c: u8x64) -> u8x64 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x64(self, a: u8x64, b: u8x64) -> mask8x64 { crate::kernel!( #[inline(always)] @@ -18082,10 +17248,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x32(self, a: i16x32) -> i16x32 { - self.count_ones_i16x32(self.not_i16x32(a)) - } - #[inline(always)] fn swap_bytes_i16x32(self, a: i16x32) -> i16x32 { let indexes = >::simd_from( self, @@ -18164,40 +17326,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i16x32(self, a: i16x32, b: i16x32) -> i16x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x32, b: i16x32) -> i16x32 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x32(self, a: i16x32, b: i16x32) -> i16x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x32, b: i16x32) -> i16x32 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x32(self, a: i16x32, b: i16x32) -> i16x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i16x32, b: i16x32) -> i16x32 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x32(self, a: i16x32) -> i16x32 { - a ^ !0 - } - #[inline(always)] fn shl_i16x32(self, a: i16x32, shift: u32) -> i16x32 { crate::kernel!( #[inline(always)] @@ -18258,14 +17386,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x32(self, a: i16x32, b: i16x32, c: i16x32) -> i16x32 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x32(self, a: i16x32, b: i16x32) -> mask16x32 { crate::kernel!( #[inline(always)] @@ -18770,10 +17890,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x32(self, a: u16x32) -> u16x32 { - self.count_ones_u16x32(self.not_u16x32(a)) - } - #[inline(always)] fn swap_bytes_u16x32(self, a: u16x32) -> u16x32 { let indexes = >::simd_from( self, @@ -18852,40 +17968,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u16x32(self, a: u16x32, b: u16x32) -> u16x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x32, b: u16x32) -> u16x32 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x32(self, a: u16x32, b: u16x32) -> u16x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x32, b: u16x32) -> u16x32 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x32(self, a: u16x32, b: u16x32) -> u16x32 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u16x32, b: u16x32) -> u16x32 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x32(self, a: u16x32) -> u16x32 { - a ^ !0 - } - #[inline(always)] fn shl_u16x32(self, a: u16x32, shift: u32) -> u16x32 { crate::kernel!( #[inline(always)] @@ -18946,14 +18028,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x32(self, a: u16x32, b: u16x32, c: u16x32) -> u16x32 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x32(self, a: u16x32, b: u16x32) -> mask16x32 { crate::kernel!( #[inline(always)] @@ -19667,10 +18741,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x16(self, a: i32x16) -> i32x16 { - self.count_ones_i32x16(self.not_i32x16(a)) - } - #[inline(always)] fn swap_bytes_i32x16(self, a: i32x16) -> i32x16 { let indexes = >::simd_from( self, @@ -19765,40 +18835,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i32x16(self, a: i32x16, b: i32x16) -> i32x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x16, b: i32x16) -> i32x16 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x16(self, a: i32x16, b: i32x16) -> i32x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x16, b: i32x16) -> i32x16 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x16(self, a: i32x16, b: i32x16) -> i32x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i32x16, b: i32x16) -> i32x16 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x16(self, a: i32x16) -> i32x16 { - a ^ !0 - } - #[inline(always)] fn shl_i32x16(self, a: i32x16, shift: u32) -> i32x16 { crate::kernel!( #[inline(always)] @@ -19859,14 +18895,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x16(self, a: i32x16, b: i32x16, c: i32x16) -> i32x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x16(self, a: i32x16, b: i32x16) -> mask32x16 { crate::kernel!( #[inline(always)] @@ -20338,10 +19366,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x16(self, a: u32x16) -> u32x16 { - self.count_ones_u32x16(self.not_u32x16(a)) - } - #[inline(always)] fn swap_bytes_u32x16(self, a: u32x16) -> u32x16 { let indexes = >::simd_from( self, @@ -20425,40 +19449,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u32x16(self, a: u32x16, b: u32x16) -> u32x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x16, b: u32x16) -> u32x16 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x16(self, a: u32x16, b: u32x16) -> u32x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x16, b: u32x16) -> u32x16 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x16(self, a: u32x16, b: u32x16) -> u32x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u32x16, b: u32x16) -> u32x16 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x16(self, a: u32x16) -> u32x16 { - a ^ !0 - } - #[inline(always)] fn shl_u32x16(self, a: u32x16, shift: u32) -> u32x16 { crate::kernel!( #[inline(always)] @@ -20519,14 +19509,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x16(self, a: u32x16, b: u32x16, c: u32x16) -> u32x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x16(self, a: u32x16, b: u32x16) -> mask32x16 { crate::kernel!( #[inline(always)] @@ -21927,10 +20909,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x8(self, a: i64x8) -> i64x8 { - self.count_ones_i64x8(self.not_i64x8(a)) - } - #[inline(always)] fn swap_bytes_i64x8(self, a: i64x8) -> i64x8 { let indexes = >::simd_from( self, @@ -22025,40 +21003,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_i64x8(self, a: i64x8, b: i64x8) -> i64x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x8, b: i64x8) -> i64x8 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x8(self, a: i64x8, b: i64x8) -> i64x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x8, b: i64x8) -> i64x8 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x8(self, a: i64x8, b: i64x8) -> i64x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: i64x8, b: i64x8) -> i64x8 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x8(self, a: i64x8) -> i64x8 { - a ^ !0 - } - #[inline(always)] fn shl_i64x8(self, a: i64x8, shift: u32) -> i64x8 { crate::kernel!( #[inline(always)] @@ -22119,14 +21063,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_i64x8(self, a: i64x8, b: i64x8, c: i64x8) -> i64x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x8(self, a: i64x8, b: i64x8) -> mask64x8 { crate::kernel!( #[inline(always)] @@ -22521,10 +21457,6 @@ impl Simd for Avx512 { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x8(self, a: u64x8) -> u64x8 { - self.count_ones_u64x8(self.not_u64x8(a)) - } - #[inline(always)] fn swap_bytes_u64x8(self, a: u64x8) -> u64x8 { let indexes = >::simd_from( self, @@ -22608,40 +21540,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn and_u64x8(self, a: u64x8, b: u64x8) -> u64x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x8, b: u64x8) -> u64x8 { - _mm512_and_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x8(self, a: u64x8, b: u64x8) -> u64x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x8, b: u64x8) -> u64x8 { - _mm512_or_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x8(self, a: u64x8, b: u64x8) -> u64x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Avx512, a: u64x8, b: u64x8) -> u64x8 { - _mm512_xor_si512(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u64x8(self, a: u64x8) -> u64x8 { - a ^ !0 - } - #[inline(always)] fn shl_u64x8(self, a: u64x8, shift: u32) -> u64x8 { crate::kernel!( #[inline(always)] @@ -22702,14 +21600,6 @@ impl Simd for Avx512 { kernel(self, a, b) } #[inline(always)] - fn clamp_u64x8(self, a: u64x8, b: u64x8, c: u64x8) -> u64x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x8(self, a: u64x8, b: u64x8) -> mask64x8 { crate::kernel!( #[inline(always)] diff --git a/fearless_simd/src/generated/fallback.rs b/fearless_simd/src/generated/fallback.rs index 13a0ae8a..60d9ab57 100644 --- a/fearless_simd/src/generated/fallback.rs +++ b/fearless_simd/src/generated/fallback.rs @@ -142,56 +142,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x4( - self, - values: f32x4, - mask: mask32x4, - merge: f32x4, - ) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x4( - self, - values: f32x4, - mask: mask32x4, - merge: f32x4, - ) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn neg_f32x4(self, a: f32x4) -> f32x4 { [ f32::neg(a[0usize]), @@ -410,14 +360,6 @@ impl Simd for Fallback { [a[1usize], a[3usize], b[1usize], b[3usize]].simd_into(self) } #[inline(always)] - fn interleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { - (self.zip_low_f32x4(a, b), self.zip_high_f32x4(a, b)) - } - #[inline(always)] - fn deinterleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { - (self.unzip_low_f32x4(a, b), self.unzip_high_f32x4(a, b)) - } - #[inline(always)] fn mul_add_f32x4(self, a: f32x4, b: f32x4, c: f32x4) -> f32x4 { a.mul(b).add(c) } @@ -514,64 +456,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { - !a.is_sign_positive() - } - #[inline(always)] - fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_f32x4(self, a: f32x4, b: f32x4) -> f32x8 { let mut result = [0.0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -702,56 +586,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i8x16(self, a: i8x16) -> i8x16 { [ i8::try_from(a[0usize].count_ones()).unwrap(), @@ -774,32 +608,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { - [ - i8::try_from(a[0usize].count_zeros()).unwrap(), - i8::try_from(a[1usize].count_zeros()).unwrap(), - i8::try_from(a[2usize].count_zeros()).unwrap(), - i8::try_from(a[3usize].count_zeros()).unwrap(), - i8::try_from(a[4usize].count_zeros()).unwrap(), - i8::try_from(a[5usize].count_zeros()).unwrap(), - i8::try_from(a[6usize].count_zeros()).unwrap(), - i8::try_from(a[7usize].count_zeros()).unwrap(), - i8::try_from(a[8usize].count_zeros()).unwrap(), - i8::try_from(a[9usize].count_zeros()).unwrap(), - i8::try_from(a[10usize].count_zeros()).unwrap(), - i8::try_from(a[11usize].count_zeros()).unwrap(), - i8::try_from(a[12usize].count_zeros()).unwrap(), - i8::try_from(a[13usize].count_zeros()).unwrap(), - i8::try_from(a[14usize].count_zeros()).unwrap(), - i8::try_from(a[15usize].count_zeros()).unwrap(), - ] - .simd_into(self) - } - #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { [ i8::reverse_bits(a[0usize]), @@ -932,94 +740,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - [ - i8::bitand(a[0usize], &b[0usize]), - i8::bitand(a[1usize], &b[1usize]), - i8::bitand(a[2usize], &b[2usize]), - i8::bitand(a[3usize], &b[3usize]), - i8::bitand(a[4usize], &b[4usize]), - i8::bitand(a[5usize], &b[5usize]), - i8::bitand(a[6usize], &b[6usize]), - i8::bitand(a[7usize], &b[7usize]), - i8::bitand(a[8usize], &b[8usize]), - i8::bitand(a[9usize], &b[9usize]), - i8::bitand(a[10usize], &b[10usize]), - i8::bitand(a[11usize], &b[11usize]), - i8::bitand(a[12usize], &b[12usize]), - i8::bitand(a[13usize], &b[13usize]), - i8::bitand(a[14usize], &b[14usize]), - i8::bitand(a[15usize], &b[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - [ - i8::bitor(a[0usize], &b[0usize]), - i8::bitor(a[1usize], &b[1usize]), - i8::bitor(a[2usize], &b[2usize]), - i8::bitor(a[3usize], &b[3usize]), - i8::bitor(a[4usize], &b[4usize]), - i8::bitor(a[5usize], &b[5usize]), - i8::bitor(a[6usize], &b[6usize]), - i8::bitor(a[7usize], &b[7usize]), - i8::bitor(a[8usize], &b[8usize]), - i8::bitor(a[9usize], &b[9usize]), - i8::bitor(a[10usize], &b[10usize]), - i8::bitor(a[11usize], &b[11usize]), - i8::bitor(a[12usize], &b[12usize]), - i8::bitor(a[13usize], &b[13usize]), - i8::bitor(a[14usize], &b[14usize]), - i8::bitor(a[15usize], &b[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - [ - i8::bitxor(a[0usize], &b[0usize]), - i8::bitxor(a[1usize], &b[1usize]), - i8::bitxor(a[2usize], &b[2usize]), - i8::bitxor(a[3usize], &b[3usize]), - i8::bitxor(a[4usize], &b[4usize]), - i8::bitxor(a[5usize], &b[5usize]), - i8::bitxor(a[6usize], &b[6usize]), - i8::bitxor(a[7usize], &b[7usize]), - i8::bitxor(a[8usize], &b[8usize]), - i8::bitxor(a[9usize], &b[9usize]), - i8::bitxor(a[10usize], &b[10usize]), - i8::bitxor(a[11usize], &b[11usize]), - i8::bitxor(a[12usize], &b[12usize]), - i8::bitxor(a[13usize], &b[13usize]), - i8::bitxor(a[14usize], &b[14usize]), - i8::bitxor(a[15usize], &b[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_i8x16(self, a: i8x16) -> i8x16 { - [ - i8::not(a[0usize]), - i8::not(a[1usize]), - i8::not(a[2usize]), - i8::not(a[3usize]), - i8::not(a[4usize]), - i8::not(a[5usize]), - i8::not(a[6usize]), - i8::not(a[7usize]), - i8::not(a[8usize]), - i8::not(a[9usize]), - i8::not(a[10usize]), - i8::not(a[11usize]), - i8::not(a[12usize]), - i8::not(a[13usize]), - i8::not(a[14usize]), - i8::not(a[15usize]), - ] - .simd_into(self) - } - #[inline(always)] fn shl_i8x16(self, a: i8x16, shift: u32) -> i8x16 { [ i8::wrapping_shl(a[0usize], shift), @@ -1252,28 +972,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - [ - i8::clamp_debug(a[0usize], b[0usize], c[0usize]), - i8::clamp_debug(a[1usize], b[1usize], c[1usize]), - i8::clamp_debug(a[2usize], b[2usize], c[2usize]), - i8::clamp_debug(a[3usize], b[3usize], c[3usize]), - i8::clamp_debug(a[4usize], b[4usize], c[4usize]), - i8::clamp_debug(a[5usize], b[5usize], c[5usize]), - i8::clamp_debug(a[6usize], b[6usize], c[6usize]), - i8::clamp_debug(a[7usize], b[7usize], c[7usize]), - i8::clamp_debug(a[8usize], b[8usize], c[8usize]), - i8::clamp_debug(a[9usize], b[9usize], c[9usize]), - i8::clamp_debug(a[10usize], b[10usize], c[10usize]), - i8::clamp_debug(a[11usize], b[11usize], c[11usize]), - i8::clamp_debug(a[12usize], b[12usize], c[12usize]), - i8::clamp_debug(a[13usize], b[13usize], c[13usize]), - i8::clamp_debug(a[14usize], b[14usize], c[14usize]), - i8::clamp_debug(a[15usize], b[15usize], c[15usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { [ -(i8::eq(&a[0usize], &b[0usize]) as i8), @@ -1375,100 +1073,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn interleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { - (self.zip_low_i8x16(a, b), self.zip_high_i8x16(a, b)) - } - #[inline(always)] - fn deinterleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { - (self.unzip_low_i8x16(a, b), self.unzip_high_i8x16(a, b)) - } - #[inline(always)] - fn select_i8x16(self, a: mask8x16, b: i8x16, c: i8x16) -> i8x16 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - if a.val.0[4usize] != 0 { - b[4usize] - } else { - c[4usize] - }, - if a.val.0[5usize] != 0 { - b[5usize] - } else { - c[5usize] - }, - if a.val.0[6usize] != 0 { - b[6usize] - } else { - c[6usize] - }, - if a.val.0[7usize] != 0 { - b[7usize] - } else { - c[7usize] - }, - if a.val.0[8usize] != 0 { - b[8usize] - } else { - c[8usize] - }, - if a.val.0[9usize] != 0 { - b[9usize] - } else { - c[9usize] - }, - if a.val.0[10usize] != 0 { - b[10usize] - } else { - c[10usize] - }, - if a.val.0[11usize] != 0 { - b[11usize] - } else { - c[11usize] - }, - if a.val.0[12usize] != 0 { - b[12usize] - } else { - c[12usize] - }, - if a.val.0[13usize] != 0 { - b[13usize] - } else { - c[13usize] - }, - if a.val.0[14usize] != 0 { - b[14usize] - } else { - c[14usize] - }, - if a.val.0[15usize] != 0 { - b[15usize] - } else { - c[15usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_i8x16(self, a: i8x16, b: i8x16) -> i8x32 { let mut result = [0; 32usize]; result[0..16usize].copy_from_slice(&a.val.0); @@ -1476,28 +1080,6 @@ impl Simd for Fallback { result.simd_into(self) } #[inline(always)] - fn neg_i8x16(self, a: i8x16) -> i8x16 { - [ - i8::wrapping_neg(a[0usize]), - i8::wrapping_neg(a[1usize]), - i8::wrapping_neg(a[2usize]), - i8::wrapping_neg(a[3usize]), - i8::wrapping_neg(a[4usize]), - i8::wrapping_neg(a[5usize]), - i8::wrapping_neg(a[6usize]), - i8::wrapping_neg(a[7usize]), - i8::wrapping_neg(a[8usize]), - i8::wrapping_neg(a[9usize]), - i8::wrapping_neg(a[10usize]), - i8::wrapping_neg(a[11usize]), - i8::wrapping_neg(a[12usize]), - i8::wrapping_neg(a[13usize]), - i8::wrapping_neg(a[14usize]), - i8::wrapping_neg(a[15usize]), - ] - .simd_into(self) - } - #[inline(always)] fn load_four_interleaved_i8x16(self, src: &[i8; 64usize]) -> [i8x16; 4usize] { [ [ @@ -1679,18 +1261,6 @@ impl Simd for Fallback { ) } #[inline(always)] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.add_i16x8(a0, b0), self.add_i16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i8x16(self, a: i8x16) -> i16x8 { [ (a[0usize] as i16) + (a[1usize] as i16), @@ -1705,12 +1275,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { - let (low, high) = self.widening_mul_i8x16(a, b); - let (even, odd) = self.deinterleave_i16x8(low, high); - self.add_i16x8(even, odd) - } - #[inline(always)] fn splat_u8x16(self, val: u8) -> u8x16 { [val; 16usize].simd_into(self) } @@ -1870,53 +1434,6 @@ impl Simd for Fallback { Bytes::from_bytes(result) } #[inline(always)] - fn compress_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16 { - self.compress_merge_u8x16(values, mask, u8x16::splat(self, 0)) - } - #[inline(always)] - fn compress_merge_u8x16( - self, - values: u8x16, - mask: mask8x16, - merge: u8x16, - ) -> u8x16 { - let mask = self.to_bitmask_mask8x16(mask); - let mut merge_padded = [0u8; 16 + 1]; - merge_padded[..16].copy_from_slice(&*merge); - let mut compacted = merge_padded; - let mut output_lane = 0; - for input_lane in 0..16 { - compacted[output_lane] = values[input_lane]; - output_lane += ((mask >> input_lane) & 1) as usize; - } - compacted[output_lane] = merge_padded[output_lane]; - let mut result = merge; - result.copy_from_slice(&compacted[..16]); - result - } - #[inline(always)] - fn expand_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16 { - self.expand_merge_u8x16(values, mask, u8x16::splat(self, 0)) - } - #[inline(always)] - fn expand_merge_u8x16( - self, - values: u8x16, - mask: mask8x16, - merge: u8x16, - ) -> u8x16 { - let mask = self.to_bitmask_mask8x16(mask); - let mut result = merge; - let mut input_lane = 0; - for output_lane in 0..16 { - let bit = ((mask >> output_lane) & 1) as u8; - let keep = 0u8.wrapping_sub(bit); - result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); - input_lane += usize::from(bit); - } - result - } - #[inline(always)] fn count_ones_u8x16(self, a: u8x16) -> u8x16 { [ u8::try_from(a[0usize].count_ones()).unwrap(), @@ -1939,32 +1456,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { - [ - u8::try_from(a[0usize].count_zeros()).unwrap(), - u8::try_from(a[1usize].count_zeros()).unwrap(), - u8::try_from(a[2usize].count_zeros()).unwrap(), - u8::try_from(a[3usize].count_zeros()).unwrap(), - u8::try_from(a[4usize].count_zeros()).unwrap(), - u8::try_from(a[5usize].count_zeros()).unwrap(), - u8::try_from(a[6usize].count_zeros()).unwrap(), - u8::try_from(a[7usize].count_zeros()).unwrap(), - u8::try_from(a[8usize].count_zeros()).unwrap(), - u8::try_from(a[9usize].count_zeros()).unwrap(), - u8::try_from(a[10usize].count_zeros()).unwrap(), - u8::try_from(a[11usize].count_zeros()).unwrap(), - u8::try_from(a[12usize].count_zeros()).unwrap(), - u8::try_from(a[13usize].count_zeros()).unwrap(), - u8::try_from(a[14usize].count_zeros()).unwrap(), - u8::try_from(a[15usize].count_zeros()).unwrap(), - ] - .simd_into(self) - } - #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { [ u8::reverse_bits(a[0usize]), @@ -2163,28 +1654,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn not_u8x16(self, a: u8x16) -> u8x16 { - [ - u8::not(a[0usize]), - u8::not(a[1usize]), - u8::not(a[2usize]), - u8::not(a[3usize]), - u8::not(a[4usize]), - u8::not(a[5usize]), - u8::not(a[6usize]), - u8::not(a[7usize]), - u8::not(a[8usize]), - u8::not(a[9usize]), - u8::not(a[10usize]), - u8::not(a[11usize]), - u8::not(a[12usize]), - u8::not(a[13usize]), - u8::not(a[14usize]), - u8::not(a[15usize]), - ] - .simd_into(self) - } - #[inline(always)] fn shl_u8x16(self, a: u8x16, shift: u32) -> u8x16 { [ u8::wrapping_shl(a[0usize], shift), @@ -2417,28 +1886,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - [ - u8::clamp_debug(a[0usize], b[0usize], c[0usize]), - u8::clamp_debug(a[1usize], b[1usize], c[1usize]), - u8::clamp_debug(a[2usize], b[2usize], c[2usize]), - u8::clamp_debug(a[3usize], b[3usize], c[3usize]), - u8::clamp_debug(a[4usize], b[4usize], c[4usize]), - u8::clamp_debug(a[5usize], b[5usize], c[5usize]), - u8::clamp_debug(a[6usize], b[6usize], c[6usize]), - u8::clamp_debug(a[7usize], b[7usize], c[7usize]), - u8::clamp_debug(a[8usize], b[8usize], c[8usize]), - u8::clamp_debug(a[9usize], b[9usize], c[9usize]), - u8::clamp_debug(a[10usize], b[10usize], c[10usize]), - u8::clamp_debug(a[11usize], b[11usize], c[11usize]), - u8::clamp_debug(a[12usize], b[12usize], c[12usize]), - u8::clamp_debug(a[13usize], b[13usize], c[13usize]), - u8::clamp_debug(a[14usize], b[14usize], c[14usize]), - u8::clamp_debug(a[15usize], b[15usize], c[15usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { [ -(u8::eq(&a[0usize], &b[0usize]) as i8), @@ -2540,100 +1987,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn interleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { - (self.zip_low_u8x16(a, b), self.zip_high_u8x16(a, b)) - } - #[inline(always)] - fn deinterleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { - (self.unzip_low_u8x16(a, b), self.unzip_high_u8x16(a, b)) - } - #[inline(always)] - fn select_u8x16(self, a: mask8x16, b: u8x16, c: u8x16) -> u8x16 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - if a.val.0[4usize] != 0 { - b[4usize] - } else { - c[4usize] - }, - if a.val.0[5usize] != 0 { - b[5usize] - } else { - c[5usize] - }, - if a.val.0[6usize] != 0 { - b[6usize] - } else { - c[6usize] - }, - if a.val.0[7usize] != 0 { - b[7usize] - } else { - c[7usize] - }, - if a.val.0[8usize] != 0 { - b[8usize] - } else { - c[8usize] - }, - if a.val.0[9usize] != 0 { - b[9usize] - } else { - c[9usize] - }, - if a.val.0[10usize] != 0 { - b[10usize] - } else { - c[10usize] - }, - if a.val.0[11usize] != 0 { - b[11usize] - } else { - c[11usize] - }, - if a.val.0[12usize] != 0 { - b[12usize] - } else { - c[12usize] - }, - if a.val.0[13usize] != 0 { - b[13usize] - } else { - c[13usize] - }, - if a.val.0[14usize] != 0 { - b[14usize] - } else { - c[14usize] - }, - if a.val.0[15usize] != 0 { - b[15usize] - } else { - c[15usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_u8x16(self, a: u8x16, b: u8x16) -> u8x32 { let mut result = [0; 32usize]; result[0..16usize].copy_from_slice(&a.val.0); @@ -2822,18 +2175,6 @@ impl Simd for Fallback { ) } #[inline(always)] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.add_u16x8(a0, b0), self.add_u16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u8x16(self, a: u8x16) -> u16x8 { [ (a[0usize] as u16) + (a[1usize] as u16), @@ -2848,12 +2189,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { - let (low, high) = self.widening_mul_u8x16(a, b); - let (even, odd) = self.deinterleave_u16x8(low, high); - self.add_u16x8(even, odd) - } - #[inline(always)] fn splat_mask8x16(self, val: bool) -> mask8x16 { let val: i8 = if val { !0 } else { 0 }; [val; 16usize].simd_into(self) @@ -2894,20 +2229,6 @@ impl Simd for Fallback { bits } #[inline(always)] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { - mask8x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { - i8x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -2919,276 +2240,45 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } + fn simd_eq_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { + [ + -(i8::eq(&a.val.0[0usize], &b.val.0[0usize]) as i8), + -(i8::eq(&a.val.0[1usize], &b.val.0[1usize]) as i8), + -(i8::eq(&a.val.0[2usize], &b.val.0[2usize]) as i8), + -(i8::eq(&a.val.0[3usize], &b.val.0[3usize]) as i8), + -(i8::eq(&a.val.0[4usize], &b.val.0[4usize]) as i8), + -(i8::eq(&a.val.0[5usize], &b.val.0[5usize]) as i8), + -(i8::eq(&a.val.0[6usize], &b.val.0[6usize]) as i8), + -(i8::eq(&a.val.0[7usize], &b.val.0[7usize]) as i8), + -(i8::eq(&a.val.0[8usize], &b.val.0[8usize]) as i8), + -(i8::eq(&a.val.0[9usize], &b.val.0[9usize]) as i8), + -(i8::eq(&a.val.0[10usize], &b.val.0[10usize]) as i8), + -(i8::eq(&a.val.0[11usize], &b.val.0[11usize]) as i8), + -(i8::eq(&a.val.0[12usize], &b.val.0[12usize]) as i8), + -(i8::eq(&a.val.0[13usize], &b.val.0[13usize]) as i8), + -(i8::eq(&a.val.0[14usize], &b.val.0[14usize]) as i8), + -(i8::eq(&a.val.0[15usize], &b.val.0[15usize]) as i8), + ] + .simd_into(self) } #[inline(always)] - fn rotate_elements_right_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - [ - i8::bitand(a.val.0[0usize], &b.val.0[0usize]), - i8::bitand(a.val.0[1usize], &b.val.0[1usize]), - i8::bitand(a.val.0[2usize], &b.val.0[2usize]), - i8::bitand(a.val.0[3usize], &b.val.0[3usize]), - i8::bitand(a.val.0[4usize], &b.val.0[4usize]), - i8::bitand(a.val.0[5usize], &b.val.0[5usize]), - i8::bitand(a.val.0[6usize], &b.val.0[6usize]), - i8::bitand(a.val.0[7usize], &b.val.0[7usize]), - i8::bitand(a.val.0[8usize], &b.val.0[8usize]), - i8::bitand(a.val.0[9usize], &b.val.0[9usize]), - i8::bitand(a.val.0[10usize], &b.val.0[10usize]), - i8::bitand(a.val.0[11usize], &b.val.0[11usize]), - i8::bitand(a.val.0[12usize], &b.val.0[12usize]), - i8::bitand(a.val.0[13usize], &b.val.0[13usize]), - i8::bitand(a.val.0[14usize], &b.val.0[14usize]), - i8::bitand(a.val.0[15usize], &b.val.0[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - [ - i8::bitor(a.val.0[0usize], &b.val.0[0usize]), - i8::bitor(a.val.0[1usize], &b.val.0[1usize]), - i8::bitor(a.val.0[2usize], &b.val.0[2usize]), - i8::bitor(a.val.0[3usize], &b.val.0[3usize]), - i8::bitor(a.val.0[4usize], &b.val.0[4usize]), - i8::bitor(a.val.0[5usize], &b.val.0[5usize]), - i8::bitor(a.val.0[6usize], &b.val.0[6usize]), - i8::bitor(a.val.0[7usize], &b.val.0[7usize]), - i8::bitor(a.val.0[8usize], &b.val.0[8usize]), - i8::bitor(a.val.0[9usize], &b.val.0[9usize]), - i8::bitor(a.val.0[10usize], &b.val.0[10usize]), - i8::bitor(a.val.0[11usize], &b.val.0[11usize]), - i8::bitor(a.val.0[12usize], &b.val.0[12usize]), - i8::bitor(a.val.0[13usize], &b.val.0[13usize]), - i8::bitor(a.val.0[14usize], &b.val.0[14usize]), - i8::bitor(a.val.0[15usize], &b.val.0[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - [ - i8::bitxor(a.val.0[0usize], &b.val.0[0usize]), - i8::bitxor(a.val.0[1usize], &b.val.0[1usize]), - i8::bitxor(a.val.0[2usize], &b.val.0[2usize]), - i8::bitxor(a.val.0[3usize], &b.val.0[3usize]), - i8::bitxor(a.val.0[4usize], &b.val.0[4usize]), - i8::bitxor(a.val.0[5usize], &b.val.0[5usize]), - i8::bitxor(a.val.0[6usize], &b.val.0[6usize]), - i8::bitxor(a.val.0[7usize], &b.val.0[7usize]), - i8::bitxor(a.val.0[8usize], &b.val.0[8usize]), - i8::bitxor(a.val.0[9usize], &b.val.0[9usize]), - i8::bitxor(a.val.0[10usize], &b.val.0[10usize]), - i8::bitxor(a.val.0[11usize], &b.val.0[11usize]), - i8::bitxor(a.val.0[12usize], &b.val.0[12usize]), - i8::bitxor(a.val.0[13usize], &b.val.0[13usize]), - i8::bitxor(a.val.0[14usize], &b.val.0[14usize]), - i8::bitxor(a.val.0[15usize], &b.val.0[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_mask8x16(self, a: mask8x16) -> mask8x16 { - [ - i8::not(a.val.0[0usize]), - i8::not(a.val.0[1usize]), - i8::not(a.val.0[2usize]), - i8::not(a.val.0[3usize]), - i8::not(a.val.0[4usize]), - i8::not(a.val.0[5usize]), - i8::not(a.val.0[6usize]), - i8::not(a.val.0[7usize]), - i8::not(a.val.0[8usize]), - i8::not(a.val.0[9usize]), - i8::not(a.val.0[10usize]), - i8::not(a.val.0[11usize]), - i8::not(a.val.0[12usize]), - i8::not(a.val.0[13usize]), - i8::not(a.val.0[14usize]), - i8::not(a.val.0[15usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { - [ - a.val.0[15usize], - a.val.0[14usize], - a.val.0[13usize], - a.val.0[12usize], - a.val.0[11usize], - a.val.0[10usize], - a.val.0[9usize], - a.val.0[8usize], - a.val.0[7usize], - a.val.0[6usize], - a.val.0[5usize], - a.val.0[4usize], - a.val.0[3usize], - a.val.0[2usize], - a.val.0[1usize], - a.val.0[0usize], - ] - .simd_into(self) - } - #[inline(always)] - fn select_mask8x16( - self, - a: mask8x16, - b: mask8x16, - c: mask8x16, - ) -> mask8x16 { - [ - if a.val.0[0usize] != 0 { - b.val.0[0usize] - } else { - c.val.0[0usize] - }, - if a.val.0[1usize] != 0 { - b.val.0[1usize] - } else { - c.val.0[1usize] - }, - if a.val.0[2usize] != 0 { - b.val.0[2usize] - } else { - c.val.0[2usize] - }, - if a.val.0[3usize] != 0 { - b.val.0[3usize] - } else { - c.val.0[3usize] - }, - if a.val.0[4usize] != 0 { - b.val.0[4usize] - } else { - c.val.0[4usize] - }, - if a.val.0[5usize] != 0 { - b.val.0[5usize] - } else { - c.val.0[5usize] - }, - if a.val.0[6usize] != 0 { - b.val.0[6usize] - } else { - c.val.0[6usize] - }, - if a.val.0[7usize] != 0 { - b.val.0[7usize] - } else { - c.val.0[7usize] - }, - if a.val.0[8usize] != 0 { - b.val.0[8usize] - } else { - c.val.0[8usize] - }, - if a.val.0[9usize] != 0 { - b.val.0[9usize] - } else { - c.val.0[9usize] - }, - if a.val.0[10usize] != 0 { - b.val.0[10usize] - } else { - c.val.0[10usize] - }, - if a.val.0[11usize] != 0 { - b.val.0[11usize] - } else { - c.val.0[11usize] - }, - if a.val.0[12usize] != 0 { - b.val.0[12usize] - } else { - c.val.0[12usize] - }, - if a.val.0[13usize] != 0 { - b.val.0[13usize] - } else { - c.val.0[13usize] - }, - if a.val.0[14usize] != 0 { - b.val.0[14usize] - } else { - c.val.0[14usize] - }, - if a.val.0[15usize] != 0 { - b.val.0[15usize] - } else { - c.val.0[15usize] - }, - ] - .simd_into(self) - } - #[inline(always)] - fn simd_eq_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - [ - -(i8::eq(&a.val.0[0usize], &b.val.0[0usize]) as i8), - -(i8::eq(&a.val.0[1usize], &b.val.0[1usize]) as i8), - -(i8::eq(&a.val.0[2usize], &b.val.0[2usize]) as i8), - -(i8::eq(&a.val.0[3usize], &b.val.0[3usize]) as i8), - -(i8::eq(&a.val.0[4usize], &b.val.0[4usize]) as i8), - -(i8::eq(&a.val.0[5usize], &b.val.0[5usize]) as i8), - -(i8::eq(&a.val.0[6usize], &b.val.0[6usize]) as i8), - -(i8::eq(&a.val.0[7usize], &b.val.0[7usize]) as i8), - -(i8::eq(&a.val.0[8usize], &b.val.0[8usize]) as i8), - -(i8::eq(&a.val.0[9usize], &b.val.0[9usize]) as i8), - -(i8::eq(&a.val.0[10usize], &b.val.0[10usize]) as i8), - -(i8::eq(&a.val.0[11usize], &b.val.0[11usize]) as i8), - -(i8::eq(&a.val.0[12usize], &b.val.0[12usize]) as i8), - -(i8::eq(&a.val.0[13usize], &b.val.0[13usize]) as i8), - -(i8::eq(&a.val.0[14usize], &b.val.0[14usize]) as i8), - -(i8::eq(&a.val.0[15usize], &b.val.0[15usize]) as i8), - ] - .simd_into(self) - } - #[inline(always)] - fn any_true_mask8x16(self, a: mask8x16) -> bool { - a.val.0[0usize] != 0 - || a.val.0[1usize] != 0 - || a.val.0[2usize] != 0 - || a.val.0[3usize] != 0 - || a.val.0[4usize] != 0 - || a.val.0[5usize] != 0 - || a.val.0[6usize] != 0 - || a.val.0[7usize] != 0 - || a.val.0[8usize] != 0 - || a.val.0[9usize] != 0 - || a.val.0[10usize] != 0 - || a.val.0[11usize] != 0 - || a.val.0[12usize] != 0 - || a.val.0[13usize] != 0 - || a.val.0[14usize] != 0 - || a.val.0[15usize] != 0 + fn any_true_mask8x16(self, a: mask8x16) -> bool { + a.val.0[0usize] != 0 + || a.val.0[1usize] != 0 + || a.val.0[2usize] != 0 + || a.val.0[3usize] != 0 + || a.val.0[4usize] != 0 + || a.val.0[5usize] != 0 + || a.val.0[6usize] != 0 + || a.val.0[7usize] != 0 + || a.val.0[8usize] != 0 + || a.val.0[9usize] != 0 + || a.val.0[10usize] != 0 + || a.val.0[11usize] != 0 + || a.val.0[12usize] != 0 + || a.val.0[13usize] != 0 + || a.val.0[14usize] != 0 + || a.val.0[15usize] != 0 } #[inline(always)] fn all_true_mask8x16(self, a: mask8x16) -> bool { @@ -3314,56 +2404,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x8( - self, - values: i16x8, - mask: mask16x8, - merge: i16x8, - ) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x8( - self, - values: i16x8, - mask: mask16x8, - merge: i16x8, - ) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i16x8(self, a: i16x8) -> i16x8 { [ i16::try_from(a[0usize].count_ones()).unwrap(), @@ -3378,20 +2418,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { - [ - i16::try_from(a[0usize].count_zeros()).unwrap(), - i16::try_from(a[1usize].count_zeros()).unwrap(), - i16::try_from(a[2usize].count_zeros()).unwrap(), - i16::try_from(a[3usize].count_zeros()).unwrap(), - i16::try_from(a[4usize].count_zeros()).unwrap(), - i16::try_from(a[5usize].count_zeros()).unwrap(), - i16::try_from(a[6usize].count_zeros()).unwrap(), - i16::try_from(a[7usize].count_zeros()).unwrap(), - ] - .simd_into(self) - } - #[inline(always)] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8 { [ i16::swap_bytes(a[0usize]), @@ -3490,62 +2516,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - [ - i16::bitand(a[0usize], &b[0usize]), - i16::bitand(a[1usize], &b[1usize]), - i16::bitand(a[2usize], &b[2usize]), - i16::bitand(a[3usize], &b[3usize]), - i16::bitand(a[4usize], &b[4usize]), - i16::bitand(a[5usize], &b[5usize]), - i16::bitand(a[6usize], &b[6usize]), - i16::bitand(a[7usize], &b[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - [ - i16::bitor(a[0usize], &b[0usize]), - i16::bitor(a[1usize], &b[1usize]), - i16::bitor(a[2usize], &b[2usize]), - i16::bitor(a[3usize], &b[3usize]), - i16::bitor(a[4usize], &b[4usize]), - i16::bitor(a[5usize], &b[5usize]), - i16::bitor(a[6usize], &b[6usize]), - i16::bitor(a[7usize], &b[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - [ - i16::bitxor(a[0usize], &b[0usize]), - i16::bitxor(a[1usize], &b[1usize]), - i16::bitxor(a[2usize], &b[2usize]), - i16::bitxor(a[3usize], &b[3usize]), - i16::bitxor(a[4usize], &b[4usize]), - i16::bitxor(a[5usize], &b[5usize]), - i16::bitxor(a[6usize], &b[6usize]), - i16::bitxor(a[7usize], &b[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_i16x8(self, a: i16x8) -> i16x8 { - [ - i16::not(a[0usize]), - i16::not(a[1usize]), - i16::not(a[2usize]), - i16::not(a[3usize]), - i16::not(a[4usize]), - i16::not(a[5usize]), - i16::not(a[6usize]), - i16::not(a[7usize]), - ] - .simd_into(self) - } - #[inline(always)] fn shl_i16x8(self, a: i16x8, shift: u32) -> i16x8 { [ i16::wrapping_shl(a[0usize], shift), @@ -3690,20 +2660,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - [ - i16::clamp_debug(a[0usize], b[0usize], c[0usize]), - i16::clamp_debug(a[1usize], b[1usize], c[1usize]), - i16::clamp_debug(a[2usize], b[2usize], c[2usize]), - i16::clamp_debug(a[3usize], b[3usize], c[3usize]), - i16::clamp_debug(a[4usize], b[4usize], c[4usize]), - i16::clamp_debug(a[5usize], b[5usize], c[5usize]), - i16::clamp_debug(a[6usize], b[6usize], c[6usize]), - i16::clamp_debug(a[7usize], b[7usize], c[7usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { [ -(i16::eq(&a[0usize], &b[0usize]) as i16), @@ -3774,60 +2730,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn interleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { - (self.zip_low_i16x8(a, b), self.zip_high_i16x8(a, b)) - } - #[inline(always)] - fn deinterleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { - (self.unzip_low_i16x8(a, b), self.unzip_high_i16x8(a, b)) - } - #[inline(always)] - fn select_i16x8(self, a: mask16x8, b: i16x8, c: i16x8) -> i16x8 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - if a.val.0[4usize] != 0 { - b[4usize] - } else { - c[4usize] - }, - if a.val.0[5usize] != 0 { - b[5usize] - } else { - c[5usize] - }, - if a.val.0[6usize] != 0 { - b[6usize] - } else { - c[6usize] - }, - if a.val.0[7usize] != 0 { - b[7usize] - } else { - c[7usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_i16x8(self, a: i16x8, b: i16x8) -> i16x16 { let mut result = [0; 16usize]; result[0..8usize].copy_from_slice(&a.val.0); @@ -3835,20 +2737,6 @@ impl Simd for Fallback { result.simd_into(self) } #[inline(always)] - fn neg_i16x8(self, a: i16x8) -> i16x8 { - [ - i16::wrapping_neg(a[0usize]), - i16::wrapping_neg(a[1usize]), - i16::wrapping_neg(a[2usize]), - i16::wrapping_neg(a[3usize]), - i16::wrapping_neg(a[4usize]), - i16::wrapping_neg(a[5usize]), - i16::wrapping_neg(a[6usize]), - i16::wrapping_neg(a[7usize]), - ] - .simd_into(self) - } - #[inline(always)] fn load_four_interleaved_i16x8(self, src: &[i16; 32usize]) -> [i16x8; 4usize] { [ [ @@ -3958,18 +2846,6 @@ impl Simd for Fallback { ) } #[inline(always)] - fn widening_mul_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.mul_i32x4(a0, b0), self.mul_i32x4(a1, b1)) - } - #[inline(always)] - fn widening_add_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.add_i32x4(a0, b0), self.add_i32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i16x8(self, a: i16x8) -> i32x4 { [ (a[0usize] as i32) + (a[1usize] as i32), @@ -3980,12 +2856,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_i16x8(self, a: i16x8, b: i16x8) -> i32x4 { - let (low, high) = self.widening_mul_i16x8(a, b); - let (even, odd) = self.deinterleave_i32x4(low, high); - self.add_i32x4(even, odd) - } - #[inline(always)] fn narrow_i16x8(self, a: i16x8, b: i16x8) -> i8x16 { [ a[0usize] as i8, @@ -4059,56 +2929,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x8( - self, - values: u16x8, - mask: mask16x8, - merge: u16x8, - ) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x8( - self, - values: u16x8, - mask: mask16x8, - merge: u16x8, - ) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u16x8(self, a: u16x8) -> u16x8 { [ u16::try_from(a[0usize].count_ones()).unwrap(), @@ -4123,20 +2943,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { - [ - u16::try_from(a[0usize].count_zeros()).unwrap(), - u16::try_from(a[1usize].count_zeros()).unwrap(), - u16::try_from(a[2usize].count_zeros()).unwrap(), - u16::try_from(a[3usize].count_zeros()).unwrap(), - u16::try_from(a[4usize].count_zeros()).unwrap(), - u16::try_from(a[5usize].count_zeros()).unwrap(), - u16::try_from(a[6usize].count_zeros()).unwrap(), - u16::try_from(a[7usize].count_zeros()).unwrap(), - ] - .simd_into(self) - } - #[inline(always)] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8 { [ u16::swap_bytes(a[0usize]), @@ -4235,62 +3041,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - [ - u16::bitand(a[0usize], &b[0usize]), - u16::bitand(a[1usize], &b[1usize]), - u16::bitand(a[2usize], &b[2usize]), - u16::bitand(a[3usize], &b[3usize]), - u16::bitand(a[4usize], &b[4usize]), - u16::bitand(a[5usize], &b[5usize]), - u16::bitand(a[6usize], &b[6usize]), - u16::bitand(a[7usize], &b[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - [ - u16::bitor(a[0usize], &b[0usize]), - u16::bitor(a[1usize], &b[1usize]), - u16::bitor(a[2usize], &b[2usize]), - u16::bitor(a[3usize], &b[3usize]), - u16::bitor(a[4usize], &b[4usize]), - u16::bitor(a[5usize], &b[5usize]), - u16::bitor(a[6usize], &b[6usize]), - u16::bitor(a[7usize], &b[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - [ - u16::bitxor(a[0usize], &b[0usize]), - u16::bitxor(a[1usize], &b[1usize]), - u16::bitxor(a[2usize], &b[2usize]), - u16::bitxor(a[3usize], &b[3usize]), - u16::bitxor(a[4usize], &b[4usize]), - u16::bitxor(a[5usize], &b[5usize]), - u16::bitxor(a[6usize], &b[6usize]), - u16::bitxor(a[7usize], &b[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_u16x8(self, a: u16x8) -> u16x8 { - [ - u16::not(a[0usize]), - u16::not(a[1usize]), - u16::not(a[2usize]), - u16::not(a[3usize]), - u16::not(a[4usize]), - u16::not(a[5usize]), - u16::not(a[6usize]), - u16::not(a[7usize]), - ] - .simd_into(self) - } - #[inline(always)] fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8 { [ u16::wrapping_shl(a[0usize], shift), @@ -4435,20 +3185,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - [ - u16::clamp_debug(a[0usize], b[0usize], c[0usize]), - u16::clamp_debug(a[1usize], b[1usize], c[1usize]), - u16::clamp_debug(a[2usize], b[2usize], c[2usize]), - u16::clamp_debug(a[3usize], b[3usize], c[3usize]), - u16::clamp_debug(a[4usize], b[4usize], c[4usize]), - u16::clamp_debug(a[5usize], b[5usize], c[5usize]), - u16::clamp_debug(a[6usize], b[6usize], c[6usize]), - u16::clamp_debug(a[7usize], b[7usize], c[7usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { [ -(u16::eq(&a[0usize], &b[0usize]) as i16), @@ -4519,60 +3255,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn interleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { - (self.zip_low_u16x8(a, b), self.zip_high_u16x8(a, b)) - } - #[inline(always)] - fn deinterleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { - (self.unzip_low_u16x8(a, b), self.unzip_high_u16x8(a, b)) - } - #[inline(always)] - fn select_u16x8(self, a: mask16x8, b: u16x8, c: u16x8) -> u16x8 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - if a.val.0[4usize] != 0 { - b[4usize] - } else { - c[4usize] - }, - if a.val.0[5usize] != 0 { - b[5usize] - } else { - c[5usize] - }, - if a.val.0[6usize] != 0 { - b[6usize] - } else { - c[6usize] - }, - if a.val.0[7usize] != 0 { - b[7usize] - } else { - c[7usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_u16x8(self, a: u16x8, b: u16x8) -> u16x16 { let mut result = [0; 16usize]; result[0..8usize].copy_from_slice(&a.val.0); @@ -4689,18 +3371,6 @@ impl Simd for Fallback { ) } #[inline(always)] - fn widening_mul_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.mul_u32x4(a0, b0), self.mul_u32x4(a1, b1)) - } - #[inline(always)] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4 { [ (a[0usize] as u32) + (a[1usize] as u32), @@ -4711,12 +3381,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { - let (low, high) = self.widening_mul_u16x8(a, b); - let (even, odd) = self.deinterleave_u32x4(low, high); - self.add_u32x4(even, odd) - } - #[inline(always)] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16 { [ a[0usize] as u8, @@ -4804,20 +3468,6 @@ impl Simd for Fallback { bits } #[inline(always)] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { - mask16x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { - i16x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -4829,180 +3479,29 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - [ - i16::bitand(a.val.0[0usize], &b.val.0[0usize]), - i16::bitand(a.val.0[1usize], &b.val.0[1usize]), - i16::bitand(a.val.0[2usize], &b.val.0[2usize]), - i16::bitand(a.val.0[3usize], &b.val.0[3usize]), - i16::bitand(a.val.0[4usize], &b.val.0[4usize]), - i16::bitand(a.val.0[5usize], &b.val.0[5usize]), - i16::bitand(a.val.0[6usize], &b.val.0[6usize]), - i16::bitand(a.val.0[7usize], &b.val.0[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + fn simd_eq_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { [ - i16::bitor(a.val.0[0usize], &b.val.0[0usize]), - i16::bitor(a.val.0[1usize], &b.val.0[1usize]), - i16::bitor(a.val.0[2usize], &b.val.0[2usize]), - i16::bitor(a.val.0[3usize], &b.val.0[3usize]), - i16::bitor(a.val.0[4usize], &b.val.0[4usize]), - i16::bitor(a.val.0[5usize], &b.val.0[5usize]), - i16::bitor(a.val.0[6usize], &b.val.0[6usize]), - i16::bitor(a.val.0[7usize], &b.val.0[7usize]), + -(i16::eq(&a.val.0[0usize], &b.val.0[0usize]) as i16), + -(i16::eq(&a.val.0[1usize], &b.val.0[1usize]) as i16), + -(i16::eq(&a.val.0[2usize], &b.val.0[2usize]) as i16), + -(i16::eq(&a.val.0[3usize], &b.val.0[3usize]) as i16), + -(i16::eq(&a.val.0[4usize], &b.val.0[4usize]) as i16), + -(i16::eq(&a.val.0[5usize], &b.val.0[5usize]) as i16), + -(i16::eq(&a.val.0[6usize], &b.val.0[6usize]) as i16), + -(i16::eq(&a.val.0[7usize], &b.val.0[7usize]) as i16), ] .simd_into(self) } #[inline(always)] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - [ - i16::bitxor(a.val.0[0usize], &b.val.0[0usize]), - i16::bitxor(a.val.0[1usize], &b.val.0[1usize]), - i16::bitxor(a.val.0[2usize], &b.val.0[2usize]), - i16::bitxor(a.val.0[3usize], &b.val.0[3usize]), - i16::bitxor(a.val.0[4usize], &b.val.0[4usize]), - i16::bitxor(a.val.0[5usize], &b.val.0[5usize]), - i16::bitxor(a.val.0[6usize], &b.val.0[6usize]), - i16::bitxor(a.val.0[7usize], &b.val.0[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_mask16x8(self, a: mask16x8) -> mask16x8 { - [ - i16::not(a.val.0[0usize]), - i16::not(a.val.0[1usize]), - i16::not(a.val.0[2usize]), - i16::not(a.val.0[3usize]), - i16::not(a.val.0[4usize]), - i16::not(a.val.0[5usize]), - i16::not(a.val.0[6usize]), - i16::not(a.val.0[7usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { - [ - a.val.0[7usize], - a.val.0[6usize], - a.val.0[5usize], - a.val.0[4usize], - a.val.0[3usize], - a.val.0[2usize], - a.val.0[1usize], - a.val.0[0usize], - ] - .simd_into(self) - } - #[inline(always)] - fn select_mask16x8( - self, - a: mask16x8, - b: mask16x8, - c: mask16x8, - ) -> mask16x8 { - [ - if a.val.0[0usize] != 0 { - b.val.0[0usize] - } else { - c.val.0[0usize] - }, - if a.val.0[1usize] != 0 { - b.val.0[1usize] - } else { - c.val.0[1usize] - }, - if a.val.0[2usize] != 0 { - b.val.0[2usize] - } else { - c.val.0[2usize] - }, - if a.val.0[3usize] != 0 { - b.val.0[3usize] - } else { - c.val.0[3usize] - }, - if a.val.0[4usize] != 0 { - b.val.0[4usize] - } else { - c.val.0[4usize] - }, - if a.val.0[5usize] != 0 { - b.val.0[5usize] - } else { - c.val.0[5usize] - }, - if a.val.0[6usize] != 0 { - b.val.0[6usize] - } else { - c.val.0[6usize] - }, - if a.val.0[7usize] != 0 { - b.val.0[7usize] - } else { - c.val.0[7usize] - }, - ] - .simd_into(self) - } - #[inline(always)] - fn simd_eq_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - [ - -(i16::eq(&a.val.0[0usize], &b.val.0[0usize]) as i16), - -(i16::eq(&a.val.0[1usize], &b.val.0[1usize]) as i16), - -(i16::eq(&a.val.0[2usize], &b.val.0[2usize]) as i16), - -(i16::eq(&a.val.0[3usize], &b.val.0[3usize]) as i16), - -(i16::eq(&a.val.0[4usize], &b.val.0[4usize]) as i16), - -(i16::eq(&a.val.0[5usize], &b.val.0[5usize]) as i16), - -(i16::eq(&a.val.0[6usize], &b.val.0[6usize]) as i16), - -(i16::eq(&a.val.0[7usize], &b.val.0[7usize]) as i16), - ] - .simd_into(self) - } - #[inline(always)] - fn any_true_mask16x8(self, a: mask16x8) -> bool { - a.val.0[0usize] != 0 - || a.val.0[1usize] != 0 - || a.val.0[2usize] != 0 - || a.val.0[3usize] != 0 - || a.val.0[4usize] != 0 - || a.val.0[5usize] != 0 - || a.val.0[6usize] != 0 - || a.val.0[7usize] != 0 + fn any_true_mask16x8(self, a: mask16x8) -> bool { + a.val.0[0usize] != 0 + || a.val.0[1usize] != 0 + || a.val.0[2usize] != 0 + || a.val.0[3usize] != 0 + || a.val.0[4usize] != 0 + || a.val.0[5usize] != 0 + || a.val.0[6usize] != 0 + || a.val.0[7usize] != 0 } #[inline(always)] fn all_true_mask16x8(self, a: mask16x8) -> bool { @@ -5111,56 +3610,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x4( - self, - values: i32x4, - mask: mask32x4, - merge: i32x4, - ) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x4( - self, - values: i32x4, - mask: mask32x4, - merge: i32x4, - ) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i32x4(self, a: i32x4) -> i32x4 { [ a[0usize].count_ones().cast_signed(), @@ -5171,16 +3620,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { - [ - a[0usize].count_zeros().cast_signed(), - a[1usize].count_zeros().cast_signed(), - a[2usize].count_zeros().cast_signed(), - a[3usize].count_zeros().cast_signed(), - ] - .simd_into(self) - } - #[inline(always)] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4 { [ i32::swap_bytes(a[0usize]), @@ -5251,46 +3690,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - [ - i32::bitand(a[0usize], &b[0usize]), - i32::bitand(a[1usize], &b[1usize]), - i32::bitand(a[2usize], &b[2usize]), - i32::bitand(a[3usize], &b[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - [ - i32::bitor(a[0usize], &b[0usize]), - i32::bitor(a[1usize], &b[1usize]), - i32::bitor(a[2usize], &b[2usize]), - i32::bitor(a[3usize], &b[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - [ - i32::bitxor(a[0usize], &b[0usize]), - i32::bitxor(a[1usize], &b[1usize]), - i32::bitxor(a[2usize], &b[2usize]), - i32::bitxor(a[3usize], &b[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_i32x4(self, a: i32x4) -> i32x4 { - [ - i32::not(a[0usize]), - i32::not(a[1usize]), - i32::not(a[2usize]), - i32::not(a[3usize]), - ] - .simd_into(self) - } - #[inline(always)] fn shl_i32x4(self, a: i32x4, shift: u32) -> i32x4 { [ i32::wrapping_shl(a[0usize], shift), @@ -5387,16 +3786,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - [ - i32::clamp_debug(a[0usize], b[0usize], c[0usize]), - i32::clamp_debug(a[1usize], b[1usize], c[1usize]), - i32::clamp_debug(a[2usize], b[2usize], c[2usize]), - i32::clamp_debug(a[3usize], b[3usize], c[3usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { [ -(i32::eq(&a[0usize], &b[0usize]) as i32), @@ -5443,40 +3832,6 @@ impl Simd for Fallback { [a[1usize], a[3usize], b[1usize], b[3usize]].simd_into(self) } #[inline(always)] - fn interleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { - (self.zip_low_i32x4(a, b), self.zip_high_i32x4(a, b)) - } - #[inline(always)] - fn deinterleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { - (self.unzip_low_i32x4(a, b), self.unzip_high_i32x4(a, b)) - } - #[inline(always)] - fn select_i32x4(self, a: mask32x4, b: i32x4, c: i32x4) -> i32x4 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_i32x4(self, a: i32x4, b: i32x4) -> i32x8 { let mut result = [0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -5484,16 +3839,6 @@ impl Simd for Fallback { result.simd_into(self) } #[inline(always)] - fn neg_i32x4(self, a: i32x4) -> i32x4 { - [ - i32::wrapping_neg(a[0usize]), - i32::wrapping_neg(a[1usize]), - i32::wrapping_neg(a[2usize]), - i32::wrapping_neg(a[3usize]), - ] - .simd_into(self) - } - #[inline(always)] fn load_four_interleaved_i32x4(self, src: &[i32; 16usize]) -> [i32x4; 4usize] { [ [src[0usize], src[4usize], src[8usize], src[12usize]].simd_into(self), @@ -5535,18 +3880,6 @@ impl Simd for Fallback { ) } #[inline(always)] - fn widening_mul_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.mul_i64x2(a0, b0), self.mul_i64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2 { [ (a[0usize] as i64) + (a[1usize] as i64), @@ -5555,12 +3888,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { - let (low, high) = self.widening_mul_i32x4(a, b); - let (even, odd) = self.deinterleave_i64x2(low, high); - self.add_i64x2(even, odd) - } - #[inline(always)] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8 { [ a[0usize] as i16, @@ -5625,56 +3952,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x4( - self, - values: u32x4, - mask: mask32x4, - merge: u32x4, - ) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x4( - self, - values: u32x4, - mask: mask32x4, - merge: u32x4, - ) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u32x4(self, a: u32x4) -> u32x4 { [ a[0usize].count_ones(), @@ -5685,16 +3962,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { - [ - a[0usize].count_zeros(), - a[1usize].count_zeros(), - a[2usize].count_zeros(), - a[3usize].count_zeros(), - ] - .simd_into(self) - } - #[inline(always)] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4 { [ u32::swap_bytes(a[0usize]), @@ -5765,46 +4032,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - [ - u32::bitand(a[0usize], &b[0usize]), - u32::bitand(a[1usize], &b[1usize]), - u32::bitand(a[2usize], &b[2usize]), - u32::bitand(a[3usize], &b[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - [ - u32::bitor(a[0usize], &b[0usize]), - u32::bitor(a[1usize], &b[1usize]), - u32::bitor(a[2usize], &b[2usize]), - u32::bitor(a[3usize], &b[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - [ - u32::bitxor(a[0usize], &b[0usize]), - u32::bitxor(a[1usize], &b[1usize]), - u32::bitxor(a[2usize], &b[2usize]), - u32::bitxor(a[3usize], &b[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_u32x4(self, a: u32x4) -> u32x4 { - [ - u32::not(a[0usize]), - u32::not(a[1usize]), - u32::not(a[2usize]), - u32::not(a[3usize]), - ] - .simd_into(self) - } - #[inline(always)] fn shl_u32x4(self, a: u32x4, shift: u32) -> u32x4 { [ u32::wrapping_shl(a[0usize], shift), @@ -5901,16 +4128,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - [ - u32::clamp_debug(a[0usize], b[0usize], c[0usize]), - u32::clamp_debug(a[1usize], b[1usize], c[1usize]), - u32::clamp_debug(a[2usize], b[2usize], c[2usize]), - u32::clamp_debug(a[3usize], b[3usize], c[3usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { [ -(u32::eq(&a[0usize], &b[0usize]) as i32), @@ -5957,40 +4174,6 @@ impl Simd for Fallback { [a[1usize], a[3usize], b[1usize], b[3usize]].simd_into(self) } #[inline(always)] - fn interleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { - (self.zip_low_u32x4(a, b), self.zip_high_u32x4(a, b)) - } - #[inline(always)] - fn deinterleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { - (self.unzip_low_u32x4(a, b), self.unzip_high_u32x4(a, b)) - } - #[inline(always)] - fn select_u32x4(self, a: mask32x4, b: u32x4, c: u32x4) -> u32x4 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - if a.val.0[2usize] != 0 { - b[2usize] - } else { - c[2usize] - }, - if a.val.0[3usize] != 0 { - b[3usize] - } else { - c[3usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_u32x4(self, a: u32x4, b: u32x4) -> u32x8 { let mut result = [0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -6039,18 +4222,6 @@ impl Simd for Fallback { ) } #[inline(always)] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2 { [ (a[0usize] as u64) + (a[1usize] as u64), @@ -6059,12 +4230,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { - let (low, high) = self.widening_mul_u32x4(a, b); - let (even, odd) = self.deinterleave_u64x2(low, high); - self.add_u64x2(even, odd) - } - #[inline(always)] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8 { [ a[0usize] as u16, @@ -6142,20 +4307,6 @@ impl Simd for Fallback { bits } #[inline(always)] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { - mask32x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { - i32x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -6167,117 +4318,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - [ - i32::bitand(a.val.0[0usize], &b.val.0[0usize]), - i32::bitand(a.val.0[1usize], &b.val.0[1usize]), - i32::bitand(a.val.0[2usize], &b.val.0[2usize]), - i32::bitand(a.val.0[3usize], &b.val.0[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - [ - i32::bitor(a.val.0[0usize], &b.val.0[0usize]), - i32::bitor(a.val.0[1usize], &b.val.0[1usize]), - i32::bitor(a.val.0[2usize], &b.val.0[2usize]), - i32::bitor(a.val.0[3usize], &b.val.0[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - [ - i32::bitxor(a.val.0[0usize], &b.val.0[0usize]), - i32::bitxor(a.val.0[1usize], &b.val.0[1usize]), - i32::bitxor(a.val.0[2usize], &b.val.0[2usize]), - i32::bitxor(a.val.0[3usize], &b.val.0[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_mask32x4(self, a: mask32x4) -> mask32x4 { - [ - i32::not(a.val.0[0usize]), - i32::not(a.val.0[1usize]), - i32::not(a.val.0[2usize]), - i32::not(a.val.0[3usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { - [ - a.val.0[3usize], - a.val.0[2usize], - a.val.0[1usize], - a.val.0[0usize], - ] - .simd_into(self) - } - #[inline(always)] - fn select_mask32x4( - self, - a: mask32x4, - b: mask32x4, - c: mask32x4, - ) -> mask32x4 { - [ - if a.val.0[0usize] != 0 { - b.val.0[0usize] - } else { - c.val.0[0usize] - }, - if a.val.0[1usize] != 0 { - b.val.0[1usize] - } else { - c.val.0[1usize] - }, - if a.val.0[2usize] != 0 { - b.val.0[2usize] - } else { - c.val.0[2usize] - }, - if a.val.0[3usize] != 0 { - b.val.0[3usize] - } else { - c.val.0[3usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { [ -(i32::eq(&a.val.0[0usize], &b.val.0[0usize]) as i32), @@ -6351,56 +4391,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x2( - self, - values: f64x2, - mask: mask64x2, - merge: f64x2, - ) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x2( - self, - values: f64x2, - mask: mask64x2, - merge: f64x2, - ) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn neg_f64x2(self, a: f64x2) -> f64x2 { [f64::neg(a[0usize]), f64::neg(a[1usize])].simd_into(self) } @@ -6563,14 +4553,6 @@ impl Simd for Fallback { [a[1usize], b[1usize]].simd_into(self) } #[inline(always)] - fn interleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { - (self.zip_low_f64x2(a, b), self.zip_high_f64x2(a, b)) - } - #[inline(always)] - fn deinterleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { - (self.unzip_low_f64x2(a, b), self.unzip_high_f64x2(a, b)) - } - #[inline(always)] fn mul_add_f64x2(self, a: f64x2, b: f64x2, c: f64x2) -> f64x2 { a.mul(b).add(c) } @@ -6623,68 +4605,20 @@ impl Simd for Fallback { [f64::to_radians(a[0usize]), f64::to_radians(a[1usize])].simd_into(self) } #[inline(always)] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_eq(f64::INFINITY) + fn combine_f64x2(self, a: f64x2, b: f64x2) -> f64x4 { + let mut result = [0.0; 4usize]; + result[0..2usize].copy_from_slice(&a.val.0); + result[2usize..4usize].copy_from_slice(&b.val.0); + result.simd_into(self) } #[inline(always)] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { - !a.is_sign_positive() - } - #[inline(always)] - fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - ] - .simd_into(self) - } - #[inline(always)] - fn combine_f64x2(self, a: f64x2, b: f64x2) -> f64x4 { - let mut result = [0.0; 4usize]; - result[0..2usize].copy_from_slice(&a.val.0); - result[2usize..4usize].copy_from_slice(&b.val.0); - result.simd_into(self) - } - #[inline(always)] - fn load_four_interleaved_f64x2(self, src: &[f64; 8usize]) -> [f64x2; 4usize] { - [ - [src[0usize], src[4usize]].simd_into(self), - [src[1usize], src[5usize]].simd_into(self), - [src[2usize], src[6usize]].simd_into(self), - [src[3usize], src[7usize]].simd_into(self), - ] + fn load_four_interleaved_f64x2(self, src: &[f64; 8usize]) -> [f64x2; 4usize] { + [ + [src[0usize], src[4usize]].simd_into(self), + [src[1usize], src[5usize]].simd_into(self), + [src[2usize], src[6usize]].simd_into(self), + [src[3usize], src[7usize]].simd_into(self), + ] } #[inline(always)] fn store_four_interleaved_f64x2( @@ -6763,56 +4697,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x2( - self, - values: i64x2, - mask: mask64x2, - merge: i64x2, - ) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x2( - self, - values: i64x2, - mask: mask64x2, - merge: i64x2, - ) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i64x2(self, a: i64x2) -> i64x2 { [ i64::from(a[0usize].count_ones()), @@ -6821,14 +4705,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { - [ - i64::from(a[0usize].count_zeros()), - i64::from(a[1usize].count_zeros()), - ] - .simd_into(self) - } - #[inline(always)] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2 { [i64::swap_bytes(a[0usize]), i64::swap_bytes(a[1usize])].simd_into(self) } @@ -6877,34 +4753,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - [ - i64::bitand(a[0usize], &b[0usize]), - i64::bitand(a[1usize], &b[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - [ - i64::bitor(a[0usize], &b[0usize]), - i64::bitor(a[1usize], &b[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - [ - i64::bitxor(a[0usize], &b[0usize]), - i64::bitxor(a[1usize], &b[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_i64x2(self, a: i64x2) -> i64x2 { - [i64::not(a[0usize]), i64::not(a[1usize])].simd_into(self) - } - #[inline(always)] fn shl_i64x2(self, a: i64x2, shift: u32) -> i64x2 { [ i64::wrapping_shl(a[0usize], shift), @@ -6973,14 +4821,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - [ - i64::clamp_debug(a[0usize], b[0usize], c[0usize]), - i64::clamp_debug(a[1usize], b[1usize], c[1usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { [ -(i64::eq(&a[0usize], &b[0usize]) as i64), @@ -7021,30 +4861,6 @@ impl Simd for Fallback { [a[1usize], b[1usize]].simd_into(self) } #[inline(always)] - fn interleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { - (self.zip_low_i64x2(a, b), self.zip_high_i64x2(a, b)) - } - #[inline(always)] - fn deinterleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { - (self.unzip_low_i64x2(a, b), self.unzip_high_i64x2(a, b)) - } - #[inline(always)] - fn select_i64x2(self, a: mask64x2, b: i64x2, c: i64x2) -> i64x2 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_i64x2(self, a: i64x2, b: i64x2) -> i64x4 { let mut result = [0; 4usize]; result[0..2usize].copy_from_slice(&a.val.0); @@ -7052,10 +4868,6 @@ impl Simd for Fallback { result.simd_into(self) } #[inline(always)] - fn neg_i64x2(self, a: i64x2) -> i64x2 { - [i64::wrapping_neg(a[0usize]), i64::wrapping_neg(a[1usize])].simd_into(self) - } - #[inline(always)] fn load_four_interleaved_i64x2(self, src: &[i64; 8usize]) -> [i64x2; 4usize] { [ [src[0usize], src[4usize]].simd_into(self), @@ -7132,56 +4944,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x2( - self, - values: u64x2, - mask: mask64x2, - merge: u64x2, - ) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x2( - self, - values: u64x2, - mask: mask64x2, - merge: u64x2, - ) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u64x2(self, a: u64x2) -> u64x2 { [ u64::from(a[0usize].count_ones()), @@ -7190,14 +4952,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { - [ - u64::from(a[0usize].count_zeros()), - u64::from(a[1usize].count_zeros()), - ] - .simd_into(self) - } - #[inline(always)] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2 { [u64::swap_bytes(a[0usize]), u64::swap_bytes(a[1usize])].simd_into(self) } @@ -7246,34 +5000,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - [ - u64::bitand(a[0usize], &b[0usize]), - u64::bitand(a[1usize], &b[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - [ - u64::bitor(a[0usize], &b[0usize]), - u64::bitor(a[1usize], &b[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - [ - u64::bitxor(a[0usize], &b[0usize]), - u64::bitxor(a[1usize], &b[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_u64x2(self, a: u64x2) -> u64x2 { - [u64::not(a[0usize]), u64::not(a[1usize])].simd_into(self) - } - #[inline(always)] fn shl_u64x2(self, a: u64x2, shift: u32) -> u64x2 { [ u64::wrapping_shl(a[0usize], shift), @@ -7342,14 +5068,6 @@ impl Simd for Fallback { .simd_into(self) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - [ - u64::clamp_debug(a[0usize], b[0usize], c[0usize]), - u64::clamp_debug(a[1usize], b[1usize], c[1usize]), - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { [ -(u64::eq(&a[0usize], &b[0usize]) as i64), @@ -7390,30 +5108,6 @@ impl Simd for Fallback { [a[1usize], b[1usize]].simd_into(self) } #[inline(always)] - fn interleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { - (self.zip_low_u64x2(a, b), self.zip_high_u64x2(a, b)) - } - #[inline(always)] - fn deinterleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { - (self.unzip_low_u64x2(a, b), self.unzip_high_u64x2(a, b)) - } - #[inline(always)] - fn select_u64x2(self, a: mask64x2, b: u64x2, c: u64x2) -> u64x2 { - [ - if a.val.0[0usize] != 0 { - b[0usize] - } else { - c[0usize] - }, - if a.val.0[1usize] != 0 { - b[1usize] - } else { - c[1usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn combine_u64x2(self, a: u64x2, b: u64x2) -> u64x4 { let mut result = [0; 4usize]; result[0..2usize].copy_from_slice(&a.val.0); @@ -7508,20 +5202,6 @@ impl Simd for Fallback { bits } #[inline(always)] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { - mask64x2 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { - i64x2 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> () { assert!( index < 2usize, @@ -7533,89 +5213,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - [ - i64::bitand(a.val.0[0usize], &b.val.0[0usize]), - i64::bitand(a.val.0[1usize], &b.val.0[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - [ - i64::bitor(a.val.0[0usize], &b.val.0[0usize]), - i64::bitor(a.val.0[1usize], &b.val.0[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - [ - i64::bitxor(a.val.0[0usize], &b.val.0[0usize]), - i64::bitxor(a.val.0[1usize], &b.val.0[1usize]), - ] - .simd_into(self) - } - #[inline(always)] - fn not_mask64x2(self, a: mask64x2) -> mask64x2 { - [i64::not(a.val.0[0usize]), i64::not(a.val.0[1usize])].simd_into(self) - } - #[inline(always)] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { - [a.val.0[1usize], a.val.0[0usize]].simd_into(self) - } - #[inline(always)] - fn select_mask64x2( - self, - a: mask64x2, - b: mask64x2, - c: mask64x2, - ) -> mask64x2 { - [ - if a.val.0[0usize] != 0 { - b.val.0[0usize] - } else { - c.val.0[0usize] - }, - if a.val.0[1usize] != 0 { - b.val.0[1usize] - } else { - c.val.0[1usize] - }, - ] - .simd_into(self) - } - #[inline(always)] fn simd_eq_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { [ -(i64::eq(&a.val.0[0usize], &b.val.0[0usize]) as i64), @@ -7664,88 +5261,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x8( - self, - values: f32x8, - mask: mask32x8, - merge: f32x8, - ) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x8( - self, - values: f32x8, - mask: mask32x8, - merge: f32x8, - ) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f32x8(self, a: f32x8, b: f32x8) -> f32x16 { let mut result = [0.0; 16usize]; result[0..8usize].copy_from_slice(&a.val.0); @@ -7768,56 +5283,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i8x32(self, a: i8x32, b: i8x32) -> i8x64 { let mut result = [0; 64usize]; result[0..32usize].copy_from_slice(&a.val.0); @@ -7907,53 +5372,6 @@ impl Simd for Fallback { Bytes::from_bytes(result) } #[inline(always)] - fn compress_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32 { - self.compress_merge_u8x32(values, mask, u8x32::splat(self, 0)) - } - #[inline(always)] - fn compress_merge_u8x32( - self, - values: u8x32, - mask: mask8x32, - merge: u8x32, - ) -> u8x32 { - let mask = self.to_bitmask_mask8x32(mask); - let mut merge_padded = [0u8; 32 + 1]; - merge_padded[..32].copy_from_slice(&*merge); - let mut compacted = merge_padded; - let mut output_lane = 0; - for input_lane in 0..32 { - compacted[output_lane] = values[input_lane]; - output_lane += ((mask >> input_lane) & 1) as usize; - } - compacted[output_lane] = merge_padded[output_lane]; - let mut result = merge; - result.copy_from_slice(&compacted[..32]); - result - } - #[inline(always)] - fn expand_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32 { - self.expand_merge_u8x32(values, mask, u8x32::splat(self, 0)) - } - #[inline(always)] - fn expand_merge_u8x32( - self, - values: u8x32, - mask: mask8x32, - merge: u8x32, - ) -> u8x32 { - let mask = self.to_bitmask_mask8x32(mask); - let mut result = merge; - let mut input_lane = 0; - for output_lane in 0..32 { - let bit = ((mask >> output_lane) & 1) as u8; - let keep = 0u8.wrapping_sub(bit); - result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); - input_lane += usize::from(bit); - } - result - } - #[inline(always)] fn combine_u8x32(self, a: u8x32, b: u8x32) -> u8x64 { let mut result = [0; 64usize]; result[0..32usize].copy_from_slice(&a.val.0); @@ -7969,20 +5387,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { - mask8x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { - i8x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -7994,36 +5398,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x64 { let mut result = [0; 64usize]; result[0..32usize].copy_from_slice(&a.val.0); @@ -8046,56 +5420,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i16x16(self, a: i16x16, b: i16x16) -> i16x32 { let mut result = [0; 32usize]; result[0..16usize].copy_from_slice(&a.val.0); @@ -8118,56 +5442,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u16x16(self, a: u16x16, b: u16x16) -> u16x32 { let mut result = [0; 32usize]; result[0..16usize].copy_from_slice(&a.val.0); @@ -8183,20 +5457,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { - mask16x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { - i16x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -8208,36 +5468,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x32 { let mut result = [0; 32usize]; result[0..16usize].copy_from_slice(&a.val.0); @@ -8260,56 +5490,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x8( - self, - values: i32x8, - mask: mask32x8, - merge: i32x8, - ) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x8( - self, - values: i32x8, - mask: mask32x8, - merge: i32x8, - ) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i32x8(self, a: i32x8, b: i32x8) -> i32x16 { let mut result = [0; 16usize]; result[0..8usize].copy_from_slice(&a.val.0); @@ -8332,56 +5512,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x8( - self, - values: u32x8, - mask: mask32x8, - merge: u32x8, - ) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x8( - self, - values: u32x8, - mask: mask32x8, - merge: u32x8, - ) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u32x8(self, a: u32x8, b: u32x8) -> u32x16 { let mut result = [0; 16usize]; result[0..8usize].copy_from_slice(&a.val.0); @@ -8397,20 +5527,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { - mask32x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { - i32x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -8422,36 +5538,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x16 { let mut result = [0; 16usize]; result[0..8usize].copy_from_slice(&a.val.0); @@ -8474,88 +5560,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x4( - self, - values: f64x4, - mask: mask64x4, - merge: f64x4, - ) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x4( - self, - values: f64x4, - mask: mask64x4, - merge: f64x4, - ) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f64x4(self, a: f64x4, b: f64x4) -> f64x8 { let mut result = [0.0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -8578,56 +5582,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x4( - self, - values: i64x4, - mask: mask64x4, - merge: i64x4, - ) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x4( - self, - values: i64x4, - mask: mask64x4, - merge: i64x4, - ) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i64x4(self, a: i64x4, b: i64x4) -> i64x8 { let mut result = [0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -8650,56 +5604,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x4( - self, - values: u64x4, - mask: mask64x4, - merge: u64x4, - ) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x4( - self, - values: u64x4, - mask: mask64x4, - merge: u64x4, - ) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u64x4(self, a: u64x4, b: u64x4) -> u64x8 { let mut result = [0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -8715,20 +5619,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { - mask64x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { - i64x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -8740,36 +5630,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x8 { let mut result = [0; 8usize]; result[0..4usize].copy_from_slice(&a.val.0); @@ -8792,88 +5652,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x16( - self, - values: f32x16, - mask: mask32x16, - merge: f32x16, - ) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x16( - self, - values: f32x16, - mask: mask32x16, - merge: f32x16, - ) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f32x16(self, a: f32x16) -> (f32x8, f32x8) { let mut b0 = [0.0; 8usize]; let mut b1 = [0.0; 8usize]; @@ -8889,56 +5667,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i8x64(self, a: i8x64) -> (i8x32, i8x32) { let mut b0 = [0; 32usize]; let mut b1 = [0; 32usize]; @@ -9021,53 +5749,6 @@ impl Simd for Fallback { Bytes::from_bytes(result) } #[inline(always)] - fn compress_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64 { - self.compress_merge_u8x64(values, mask, u8x64::splat(self, 0)) - } - #[inline(always)] - fn compress_merge_u8x64( - self, - values: u8x64, - mask: mask8x64, - merge: u8x64, - ) -> u8x64 { - let mask = self.to_bitmask_mask8x64(mask); - let mut merge_padded = [0u8; 64 + 1]; - merge_padded[..64].copy_from_slice(&*merge); - let mut compacted = merge_padded; - let mut output_lane = 0; - for input_lane in 0..64 { - compacted[output_lane] = values[input_lane]; - output_lane += ((mask >> input_lane) & 1) as usize; - } - compacted[output_lane] = merge_padded[output_lane]; - let mut result = merge; - result.copy_from_slice(&compacted[..64]); - result - } - #[inline(always)] - fn expand_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64 { - self.expand_merge_u8x64(values, mask, u8x64::splat(self, 0)) - } - #[inline(always)] - fn expand_merge_u8x64( - self, - values: u8x64, - mask: mask8x64, - merge: u8x64, - ) -> u8x64 { - let mask = self.to_bitmask_mask8x64(mask); - let mut result = merge; - let mut input_lane = 0; - for output_lane in 0..64 { - let bit = ((mask >> output_lane) & 1) as u8; - let keep = 0u8.wrapping_sub(bit); - result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); - input_lane += usize::from(bit); - } - result - } - #[inline(always)] fn split_u8x64(self, a: u8x64) -> (u8x32, u8x32) { let mut b0 = [0; 32usize]; let mut b1 = [0; 32usize]; @@ -9076,20 +5757,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { - mask8x64 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { - i8x64 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> () { assert!( index < 64usize, @@ -9101,36 +5768,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask8x64(self, a: mask8x64) -> (mask8x32, mask8x32) { let mut b0 = [0; 32usize]; let mut b1 = [0; 32usize]; @@ -9146,56 +5783,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i16x32(self, a: i16x32) -> (i16x16, i16x16) { let mut b0 = [0; 16usize]; let mut b1 = [0; 16usize]; @@ -9211,56 +5798,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u16x32(self, a: u16x32) -> (u16x16, u16x16) { let mut b0 = [0; 16usize]; let mut b1 = [0; 16usize]; @@ -9269,20 +5806,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { - mask16x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { - i16x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -9294,36 +5817,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask16x32(self, a: mask16x32) -> (mask16x16, mask16x16) { let mut b0 = [0; 16usize]; let mut b1 = [0; 16usize]; @@ -9339,56 +5832,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x16( - self, - values: i32x16, - mask: mask32x16, - merge: i32x16, - ) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x16( - self, - values: i32x16, - mask: mask32x16, - merge: i32x16, - ) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i32x16(self, a: i32x16) -> (i32x8, i32x8) { let mut b0 = [0; 8usize]; let mut b1 = [0; 8usize]; @@ -9404,56 +5847,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x16( - self, - values: u32x16, - mask: mask32x16, - merge: u32x16, - ) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x16( - self, - values: u32x16, - mask: mask32x16, - merge: u32x16, - ) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u32x16(self, a: u32x16) -> (u32x8, u32x8) { let mut b0 = [0; 8usize]; let mut b1 = [0; 8usize]; @@ -9462,20 +5855,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { - mask32x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { - i32x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -9487,36 +5866,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask32x16(self, a: mask32x16) -> (mask32x8, mask32x8) { let mut b0 = [0; 8usize]; let mut b1 = [0; 8usize]; @@ -9532,88 +5881,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x8( - self, - values: f64x8, - mask: mask64x8, - merge: f64x8, - ) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x8( - self, - values: f64x8, - mask: mask64x8, - merge: f64x8, - ) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f64x8(self, a: f64x8) -> (f64x4, f64x4) { let mut b0 = [0.0; 4usize]; let mut b1 = [0.0; 4usize]; @@ -9629,56 +5896,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x8( - self, - values: i64x8, - mask: mask64x8, - merge: i64x8, - ) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x8( - self, - values: i64x8, - mask: mask64x8, - merge: i64x8, - ) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i64x8(self, a: i64x8) -> (i64x4, i64x4) { let mut b0 = [0; 4usize]; let mut b1 = [0; 4usize]; @@ -9694,56 +5911,6 @@ impl Simd for Fallback { dest.simd_into(self) } #[inline(always)] - fn compress_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x8( - self, - values: u64x8, - mask: mask64x8, - merge: u64x8, - ) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x8( - self, - values: u64x8, - mask: mask64x8, - merge: u64x8, - ) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u64x8(self, a: u64x8) -> (u64x4, u64x4) { let mut b0 = [0; 4usize]; let mut b1 = [0; 4usize]; @@ -9752,20 +5919,6 @@ impl Simd for Fallback { (b0.simd_into(self), b1.simd_into(self)) } #[inline(always)] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { - mask64x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { - i64x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -9777,36 +5930,6 @@ impl Simd for Fallback { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask64x8(self, a: mask64x8) -> (mask64x4, mask64x4) { let mut b0 = [0; 4usize]; let mut b1 = [0; 4usize]; diff --git a/fearless_simd/src/generated/neon.rs b/fearless_simd/src/generated/neon.rs index 4b8fcf03..350a6e6f 100644 --- a/fearless_simd/src/generated/neon.rs +++ b/fearless_simd/src/generated/neon.rs @@ -519,14 +519,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { - (self.zip_low_f32x4(a, b), self.zip_high_f32x4(a, b)) - } - #[inline(always)] - fn deinterleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { - (self.unzip_low_f32x4(a, b), self.unzip_high_f32x4(a, b)) - } - #[inline(always)] fn mul_add_f32x4(self, a: f32x4, b: f32x4, c: f32x4) -> f32x4 { crate::kernel!( #[inline(always)] @@ -617,38 +609,6 @@ impl Simd for Neon { a * const { f32::to_radians(1.0) } } #[inline(always)] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { crate::kernel!( #[inline(always)] @@ -838,14 +798,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { - self.count_ones_i8x16(self.not_i8x16(a)) - } - #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -908,36 +860,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i8x16, b: i8x16) -> i8x16 { - vandq_s8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i8x16, b: i8x16) -> i8x16 { - vorrq_s8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i8x16, b: i8x16) -> i8x16 { - veorq_s8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1053,14 +975,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -1139,14 +1053,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { - (self.zip_low_i8x16(a, b), self.zip_high_i8x16(a, b)) - } - #[inline(always)] - fn deinterleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { - (self.unzip_low_i8x16(a, b), self.unzip_high_i8x16(a, b)) - } - #[inline(always)] fn select_i8x16(self, a: mask8x16, b: i8x16, c: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1491,14 +1397,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { - self.count_ones_u8x16(self.not_u8x16(a)) - } - #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1706,14 +1604,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -1792,14 +1682,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { - (self.zip_low_u8x16(a, b), self.zip_high_u8x16(a, b)) - } - #[inline(always)] - fn deinterleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { - (self.unzip_low_u8x16(a, b), self.unzip_high_u8x16(a, b)) - } - #[inline(always)] fn select_u8x16(self, a: mask8x16, b: u8x16, c: u8x16) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1951,20 +1833,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { - mask8x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { - i8x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -1976,88 +1844,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask8x16, b: mask8x16) -> mask8x16 { - vandq_s8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask8x16, b: mask8x16) -> mask8x16 { - vorrq_s8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask8x16, b: mask8x16) -> mask8x16 { - veorq_s8(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask8x16(self, a: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask8x16) -> mask8x16 { - vmvnq_s8(a.into()).simd_into(token) - } - ); - kernel(self, a) - } - #[inline(always)] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { - let lanes = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i8x16(lanes); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask8x16( self, a: mask8x16, @@ -2285,10 +2071,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { - self.count_ones_i16x8(self.not_i16x8(a)) - } - #[inline(always)] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8 { crate::kernel!( #[inline(always)] @@ -2361,36 +2143,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i16x8, b: i16x8) -> i16x8 { - vandq_s16(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i16x8, b: i16x8) -> i16x8 { - vorrq_s16(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i16x8, b: i16x8) -> i16x8 { - veorq_s16(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_i16x8(self, a: i16x8) -> i16x8 { crate::kernel!( #[inline(always)] @@ -2505,14 +2257,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -2591,14 +2335,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { - (self.zip_low_i16x8(a, b), self.zip_high_i16x8(a, b)) - } - #[inline(always)] - fn deinterleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { - (self.unzip_low_i16x8(a, b), self.unzip_high_i16x8(a, b)) - } - #[inline(always)] fn select_i16x8(self, a: mask16x8, b: i16x8, c: i16x8) -> i16x8 { crate::kernel!( #[inline(always)] @@ -2872,10 +2608,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { - self.count_ones_u16x8(self.not_u16x8(a)) - } - #[inline(always)] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8 { crate::kernel!( #[inline(always)] @@ -2948,36 +2680,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u16x8, b: u16x8) -> u16x8 { - vandq_u16(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u16x8, b: u16x8) -> u16x8 { - vorrq_u16(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u16x8, b: u16x8) -> u16x8 { - veorq_u16(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_u16x8(self, a: u16x8) -> u16x8 { crate::kernel!( #[inline(always)] @@ -3092,14 +2794,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3178,14 +2872,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { - (self.zip_low_u16x8(a, b), self.zip_high_u16x8(a, b)) - } - #[inline(always)] - fn deinterleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { - (self.unzip_low_u16x8(a, b), self.unzip_high_u16x8(a, b)) - } - #[inline(always)] fn select_u16x8(self, a: mask16x8, b: u16x8, c: u16x8) -> u16x8 { crate::kernel!( #[inline(always)] @@ -3363,20 +3049,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { - mask16x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { - i16x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -3388,143 +3060,61 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x8( + fn select_mask16x8( self, a: mask16x8, + b: mask16x8, + c: mask16x8, ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } + crate::kernel!( + #[inline(always)] + fn kernel( + token: Neon, + a: mask16x8, + b: mask16x8, + c: mask16x8, + ) -> mask16x8 { + vbslq_s16(vreinterpretq_u16_s16(a.into()), b.into(), c.into()).simd_into(token) + } + ); + kernel(self, a, b, c) } #[inline(always)] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + fn simd_eq_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { crate::kernel!( #[inline(always)] fn kernel(token: Neon, a: mask16x8, b: mask16x8) -> mask16x8 { - vandq_s16(a.into(), b.into()).simd_into(token) + vreinterpretq_s16_u16(vceqq_s16(a.into(), b.into())).simd_into(token) } ); kernel(self, a, b) } #[inline(always)] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + fn any_true_mask16x8(self, a: mask16x8) -> bool { crate::kernel!( #[inline(always)] - fn kernel(token: Neon, a: mask16x8, b: mask16x8) -> mask16x8 { - vorrq_s16(a.into(), b.into()).simd_into(token) + fn kernel(token: Neon, a: mask16x8) -> bool { + vmaxvq_u32(vreinterpretq_u32_s16(a.into())) != 0 } ); - kernel(self, a, b) + kernel(self, a) } #[inline(always)] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + fn all_true_mask16x8(self, a: mask16x8) -> bool { crate::kernel!( #[inline(always)] - fn kernel(token: Neon, a: mask16x8, b: mask16x8) -> mask16x8 { - veorq_s16(a.into(), b.into()).simd_into(token) + fn kernel(token: Neon, a: mask16x8) -> bool { + vminvq_u32(vreinterpretq_u32_s16(a.into())) == 0xffffffff } ); - kernel(self, a, b) + kernel(self, a) } #[inline(always)] - fn not_mask16x8(self, a: mask16x8) -> mask16x8 { + fn any_false_mask16x8(self, a: mask16x8) -> bool { crate::kernel!( #[inline(always)] - fn kernel(token: Neon, a: mask16x8) -> mask16x8 { - vmvnq_s16(a.into()).simd_into(token) - } - ); - kernel(self, a) - } - #[inline(always)] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { - let lanes = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i16x8(lanes); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] - fn select_mask16x8( - self, - a: mask16x8, - b: mask16x8, - c: mask16x8, - ) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel( - token: Neon, - a: mask16x8, - b: mask16x8, - c: mask16x8, - ) -> mask16x8 { - vbslq_s16(vreinterpretq_u16_s16(a.into()), b.into(), c.into()).simd_into(token) - } - ); - kernel(self, a, b, c) - } - #[inline(always)] - fn simd_eq_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask16x8, b: mask16x8) -> mask16x8 { - vreinterpretq_s16_u16(vceqq_s16(a.into(), b.into())).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn any_true_mask16x8(self, a: mask16x8) -> bool { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask16x8) -> bool { - vmaxvq_u32(vreinterpretq_u32_s16(a.into())) != 0 - } - ); - kernel(self, a) - } - #[inline(always)] - fn all_true_mask16x8(self, a: mask16x8) -> bool { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask16x8) -> bool { - vminvq_u32(vreinterpretq_u32_s16(a.into())) == 0xffffffff - } - ); - kernel(self, a) - } - #[inline(always)] - fn any_false_mask16x8(self, a: mask16x8) -> bool { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask16x8) -> bool { - vminvq_u32(vreinterpretq_u32_s16(a.into())) != 0xffffffff + fn kernel(token: Neon, a: mask16x8) -> bool { + vminvq_u32(vreinterpretq_u32_s16(a.into())) != 0xffffffff } ); kernel(self, a) @@ -3709,10 +3299,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { - self.count_ones_i32x4(self.not_i32x4(a)) - } - #[inline(always)] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4 { crate::kernel!( #[inline(always)] @@ -3785,36 +3371,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i32x4, b: i32x4) -> i32x4 { - vandq_s32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i32x4, b: i32x4) -> i32x4 { - vorrq_s32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i32x4, b: i32x4) -> i32x4 { - veorq_s32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_i32x4(self, a: i32x4) -> i32x4 { crate::kernel!( #[inline(always)] @@ -3928,14 +3484,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -4014,14 +3562,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { - (self.zip_low_i32x4(a, b), self.zip_high_i32x4(a, b)) - } - #[inline(always)] - fn deinterleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { - (self.unzip_low_i32x4(a, b), self.unzip_high_i32x4(a, b)) - } - #[inline(always)] fn select_i32x4(self, a: mask32x4, b: i32x4, c: i32x4) -> i32x4 { crate::kernel!( #[inline(always)] @@ -4305,10 +3845,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { - self.count_ones_u32x4(self.not_u32x4(a)) - } - #[inline(always)] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4 { crate::kernel!( #[inline(always)] @@ -4381,36 +3917,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u32x4, b: u32x4) -> u32x4 { - vandq_u32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u32x4, b: u32x4) -> u32x4 { - vorrq_u32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u32x4, b: u32x4) -> u32x4 { - veorq_u32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_u32x4(self, a: u32x4) -> u32x4 { crate::kernel!( #[inline(always)] @@ -4524,14 +4030,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -4610,14 +4108,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { - (self.zip_low_u32x4(a, b), self.zip_high_u32x4(a, b)) - } - #[inline(always)] - fn deinterleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { - (self.unzip_low_u32x4(a, b), self.unzip_high_u32x4(a, b)) - } - #[inline(always)] fn select_u32x4(self, a: mask32x4, b: u32x4, c: u32x4) -> u32x4 { crate::kernel!( #[inline(always)] @@ -4804,20 +4294,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { - mask32x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { - i32x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -4829,88 +4305,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask32x4, b: mask32x4) -> mask32x4 { - vandq_s32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask32x4, b: mask32x4) -> mask32x4 { - vorrq_s32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask32x4, b: mask32x4) -> mask32x4 { - veorq_s32(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask32x4(self, a: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask32x4) -> mask32x4 { - vmvnq_s32(a.into()).simd_into(token) - } - ); - kernel(self, a) - } - #[inline(always)] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { - let lanes = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i32x4(lanes); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask32x4( self, a: mask32x4, @@ -5411,14 +4805,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { - (self.zip_low_f64x2(a, b), self.zip_high_f64x2(a, b)) - } - #[inline(always)] - fn deinterleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { - (self.unzip_low_f64x2(a, b), self.unzip_high_f64x2(a, b)) - } - #[inline(always)] fn mul_add_f64x2(self, a: f64x2, b: f64x2, c: f64x2) -> f64x2 { crate::kernel!( #[inline(always)] @@ -5509,38 +4895,6 @@ impl Simd for Neon { a * const { f64::to_radians(1.0) } } #[inline(always)] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { crate::kernel!( #[inline(always)] @@ -5772,10 +5126,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { - self.count_ones_i64x2(self.not_i64x2(a)) - } - #[inline(always)] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2 { crate::kernel!( #[inline(always)] @@ -5846,36 +5196,6 @@ impl Simd for Neon { .simd_into(self) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i64x2, b: i64x2) -> i64x2 { - vandq_s64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i64x2, b: i64x2) -> i64x2 { - vorrq_s64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: i64x2, b: i64x2) -> i64x2 { - veorq_s64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_i64x2(self, a: i64x2) -> i64x2 { crate::kernel!( #[inline(always)] @@ -5967,14 +5287,6 @@ impl Simd for Neon { .simd_into(self) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -6053,14 +5365,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { - (self.zip_low_i64x2(a, b), self.zip_high_i64x2(a, b)) - } - #[inline(always)] - fn deinterleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { - (self.unzip_low_i64x2(a, b), self.unzip_high_i64x2(a, b)) - } - #[inline(always)] fn select_i64x2(self, a: mask64x2, b: i64x2, c: i64x2) -> i64x2 { crate::kernel!( #[inline(always)] @@ -6287,10 +5591,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { - self.count_ones_u64x2(self.not_u64x2(a)) - } - #[inline(always)] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2 { crate::kernel!( #[inline(always)] @@ -6361,36 +5661,6 @@ impl Simd for Neon { .simd_into(self) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u64x2, b: u64x2) -> u64x2 { - vandq_u64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u64x2, b: u64x2) -> u64x2 { - vorrq_u64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: u64x2, b: u64x2) -> u64x2 { - veorq_u64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] fn not_u64x2(self, a: u64x2) -> u64x2 { crate::kernel!( #[inline(always)] @@ -6482,14 +5752,6 @@ impl Simd for Neon { .simd_into(self) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -6568,14 +5830,6 @@ impl Simd for Neon { kernel(self, a, b) } #[inline(always)] - fn interleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { - (self.zip_low_u64x2(a, b), self.zip_high_u64x2(a, b)) - } - #[inline(always)] - fn deinterleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { - (self.unzip_low_u64x2(a, b), self.unzip_high_u64x2(a, b)) - } - #[inline(always)] fn select_u64x2(self, a: mask64x2, b: u64x2, c: u64x2) -> u64x2 { crate::kernel!( #[inline(always)] @@ -6701,20 +5955,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { - mask64x2 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { - i64x2 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> () { assert!( index < 2usize, @@ -6726,88 +5966,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask64x2, b: mask64x2) -> mask64x2 { - vandq_s64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask64x2, b: mask64x2) -> mask64x2 { - vorrq_s64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask64x2, b: mask64x2) -> mask64x2 { - veorq_s64(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask64x2(self, a: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Neon, a: mask64x2) -> mask64x2 { - vreinterpretq_s64_s32(vmvnq_s32(vreinterpretq_s32_s64(a.into()))).simd_into(token) - } - ); - kernel(self, a) - } - #[inline(always)] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { - let lanes = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i64x2(lanes); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask64x2( self, a: mask64x2, @@ -6974,44 +6132,12 @@ impl Simd for Neon { let mask = mask8x32 { val: crate::transmute::checked_transmute_copy(&mask.val), simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { - !a.is_sign_positive() + }; + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) } #[inline(always)] fn combine_f32x8(self, a: f32x8, b: f32x8) -> f32x16 { @@ -7411,20 +6537,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { - mask8x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { - i8x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -7436,36 +6548,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x64 { mask8x64 { val: crate::support::Aligned512(int8x16x4_t( @@ -7721,20 +6803,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { - mask16x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { - i16x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -7746,36 +6814,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x32 { mask16x32 { val: crate::support::Aligned512(int16x8x4_t( @@ -8031,20 +7069,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { - mask32x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { - i32x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -8056,36 +7080,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x16 { mask32x16 { val: crate::support::Aligned512(int32x4x4_t( @@ -8195,38 +7189,6 @@ impl Simd for Neon { )) } #[inline(always)] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f64x4(self, a: f64x4, b: f64x4) -> f64x8 { f64x8 { val: crate::support::Aligned512(float64x2x4_t( @@ -8482,20 +7444,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { - mask64x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { - i64x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -8507,36 +7455,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x8 { mask64x8 { val: crate::support::Aligned512(int64x2x4_t( @@ -8664,38 +7582,6 @@ impl Simd for Neon { )) } #[inline(always)] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f32x16(self, a: f32x16) -> (f32x8, f32x8) { ( f32x8 { @@ -9113,20 +7999,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { - mask8x64 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { - i8x64 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> () { assert!( index < 64usize, @@ -9138,36 +8010,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask8x64(self, a: mask8x64) -> (mask8x32, mask8x32) { ( mask8x32 { @@ -9437,20 +8279,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { - mask16x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { - i16x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -9462,36 +8290,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask16x32(self, a: mask16x32) -> (mask16x16, mask16x16) { ( mask16x16 { @@ -9761,20 +8559,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { - mask32x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { - i32x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -9786,36 +8570,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask32x16(self, a: mask32x16) -> (mask32x8, mask32x8) { ( mask32x8 { @@ -9934,38 +8688,6 @@ impl Simd for Neon { )) } #[inline(always)] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f64x8(self, a: f64x8) -> (f64x4, f64x4) { ( f64x4 { @@ -10235,20 +8957,6 @@ impl Simd for Neon { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { - mask64x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { - i64x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -10260,36 +8968,6 @@ impl Simd for Neon { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask64x8(self, a: mask64x8) -> (mask64x4, mask64x4) { ( mask64x4 { diff --git a/fearless_simd/src/generated/simd_trait.rs b/fearless_simd/src/generated/simd_trait.rs index eeaf61c1..2ae831b0 100644 --- a/fearless_simd/src/generated/simd_trait.rs +++ b/fearless_simd/src/generated/simd_trait.rs @@ -295,23 +295,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4; + #[inline(always)] + fn compress_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_f32x4( self, values: f32x4, mask: mask32x4, merge: f32x4, - ) -> f32x4; + ) -> f32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4; + #[inline(always)] + fn expand_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_f32x4( self, values: f32x4, mask: mask32x4, merge: f32x4, - ) -> f32x4; + ) -> f32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Negate each element of the vector."] fn neg_f32x4(self, a: f32x4) -> f32x4; #[doc = "Compute the square root of each element.\n\nNegative elements other than `-0.0` will become NaN."] @@ -380,9 +404,15 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_f32x4(self, a: f32x4, b: f32x4) -> f32x4; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4); + #[inline(always)] + fn interleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { + (self.zip_low_f32x4(a, b), self.zip_high_f32x4(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4); + #[inline(always)] + fn deinterleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { + (self.unzip_low_f32x4(a, b), self.unzip_high_f32x4(a, b)) + } #[doc = "Compute `(a * b) + c` (potentially fused multiply-add) for each element.\n\nThe result may be computed with one or two rounding errors depending on which can be computed faster on the current platform."] fn mul_add_f32x4(self, a: f32x4, b: f32x4, c: f32x4) -> f32x4; #[doc = "Compute `(a * b) + c` for each element, with a single rounding at the end.\n\nThe result is the infinite-precision product-plus-add rounded once to the element type. This may be substantially slower than `mul_add` on platforms without fused multiply-add instructions, including WebAssembly.\n\n# Precision guarantees\n\nThis function is **not** susceptible to [the bug](https://github.com/rust-lang/compiler-builtins/issues/1262) in Rust standard library and in musl libc that causes incorrect rounding for near-zero values on CPUs without hardware support for this operation.\n\nOn the tier-2 i586-* targets, this function is correct if and only if SSE2 is available on the CPU.\n\nThe exact `NaN` payloads as well as signaling `NaN`s are not preserved.\n\n# Performance\n\nThe following platforms will use a single fused multiply-add instruction for this operation: ARM NEON, x86 AVX2, and x86 AVX512."] @@ -408,21 +438,52 @@ pub trait Simd: #[doc = "Converts degrees to radians.\n\nThe precision of this function is non-deterministic. This means it varies by platform, Rust version, and can even differ within the same execution from one invocation to the next."] fn to_radians_f32x4(self, a: f32x4) -> f32x4; #[doc = "Return a mask indicating which elements are NaN."] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { + a.simd_ne(a) + } #[doc = "Return a mask indicating which elements are positive or negative infinite."] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { + a.abs().simd_eq(f32::INFINITY) + } #[doc = "Return a mask indicating which elements are neither infinite nor NaN."] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { + a.abs().simd_lt(f32::INFINITY) + } #[doc = "Return a mask indicating which elements are subnormal.\n\nThis classifies the stored bit pattern, even when floating-point operations treat subnormals as zero."] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { + let i: i32x4 = a.bitcast(); + (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) + } #[doc = "Return a mask indicating which elements are neither zero, infinite, subnormal, or NaN."] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { + let i: i32x4 = a.bitcast(); + let exp = i & 0x7F80_0000_i32; + exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) + } #[doc = "Return a mask indicating which elements have a positive sign, including `+0.0`, NaNs with positive sign bit and positive infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_positive`] for details."] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { + let i: i32x4 = a.bitcast(); + (i & i32::MIN).simd_eq(0) + } #[doc = "Return a mask indicating which elements have a negative sign, including `-0.0`, NaNs with negative sign bit and negative infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_negative`] for details."] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4; + #[inline(always)] + fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { + !a.is_sign_positive() + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4; + #[inline(always)] + fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_f32x4(self, a: f32x4, b: f32x4) -> f32x8; #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] @@ -506,29 +567,59 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16; + #[inline(always)] + fn compress_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i8x16( self, values: i8x16, mask: mask8x16, merge: i8x16, - ) -> i8x16; + ) -> i8x16 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16; + #[inline(always)] + fn expand_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i8x16( self, values: i8x16, mask: mask8x16, merge: i8x16, - ) -> i8x16; + ) -> i8x16 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_i8x16(self, a: i8x16) -> i8x16; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16; + #[inline(always)] + fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { + self.count_ones_i8x16(self.not_i8x16(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16; + #[inline(always)] + fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { + a + } #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16; #[doc = "Add two vectors element-wise, wrapping on overflow."] @@ -542,13 +633,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_i8x16(self, a: i8x16, b: i8x16) -> i8x16; #[doc = "Compute the bitwise AND of two vectors."] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16; + #[inline(always)] + fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16; + #[inline(always)] + fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16; + #[inline(always)] + fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_i8x16(self, a: i8x16) -> i8x16; + #[inline(always)] + fn not_i8x16(self, a: i8x16) -> i8x16 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_i8x16(self, a: i8x16, shift: u32) -> i8x16; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -570,7 +673,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_i8x16(self, a: i8x16, b: i8x16) -> i8x16; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16; + #[inline(always)] + fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -601,15 +711,30 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_i8x16(self, a: i8x16, b: i8x16) -> i8x16; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16); + #[inline(always)] + fn interleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { + (self.zip_low_i8x16(a, b), self.zip_high_i8x16(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16); + #[inline(always)] + fn deinterleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { + (self.unzip_low_i8x16(a, b), self.unzip_high_i8x16(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_i8x16(self, a: mask8x16, b: i8x16, c: i8x16) -> i8x16; + #[inline(always)] + fn select_i8x16(self, a: mask8x16, b: i8x16, c: i8x16) -> i8x16 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_i8x16(self, a: i8x16, b: i8x16) -> i8x32; #[doc = "Negate each element of the vector, wrapping on overflow."] - fn neg_i8x16(self, a: i8x16) -> i8x16; + #[inline(always)] + fn neg_i8x16(self, a: i8x16) -> i8x16 { + self.sub_i8x16(self.splat_i8x16(0), a) + } #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] #[doc(alias = "load_interleaved")] fn load_four_interleaved_i8x16(self, src: &[i8; 64usize]) -> [i8x16; 4usize]; @@ -623,13 +748,28 @@ pub trait Simd: #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] fn widen_i8x16(self, a: i8x16) -> (i16x8, i16x8); #[doc = "Multiply corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8); + #[inline(always)] + fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { + let (a0, a1) = self.widen_i8x16(a); + let (b0, b1) = self.widen_i8x16(b); + (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) + } #[doc = "Add corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8); + #[inline(always)] + fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { + let (a0, a1) = self.widen_i8x16(a); + let (b0, b1) = self.widen_i8x16(b); + (self.add_i16x8(a0, b0), self.add_i16x8(a1, b1)) + } #[doc = "Add adjacent integer lanes exactly into twice-wide lanes.\n\nOutput lane `i` is `widen(a[2*i]) + widen(a[2*i+1])`. The result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. The sum cannot overflow the widened type.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` produces `[3, 7, 11, 15]`. See [`SimdIntWiden::pairwise_widening_add`] for supported types and examples."] fn pairwise_widening_add_i8x16(self, a: i8x16) -> i16x8; #[doc = "Multiply corresponding integer lanes exactly in the widened type, then sum adjacent pairs of products.\n\nThe result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. Lane `i` is `widen(a[2*i]) * widen(b[2*i]) + widen(a[2*i+1]) * widen(b[2*i+1])`; addition wraps in the destination type, including in debug builds.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` and `[10, 20, 30, 40, 50, 60, 70, 80]` produce `[50, 250, 610, 1130]`. See [`SimdIntWiden::pairwise_dot_product`] for examples."] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8; + #[inline(always)] + fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { + let (low, high) = self.widening_mul_i8x16(a, b); + let (even, odd) = self.deinterleave_i16x8(low, high); + self.add_i16x8(even, odd) + } #[doc = "Compute the absolute value of each element.\n\nUnsigned integers are unchanged. Signed integers use wrapping absolute value: the minimum representable value remains unchanged. This matches `i32::abs()`.\n\nFor floating-point elements, clear the sign bit, preserving all other bits. For example, negative zero becomes positive zero."] #[inline(always)] fn abs_u8x16(self, a: u8x16) -> u8x16 { @@ -671,29 +811,68 @@ pub trait Simd: indices: u8x16, ) -> u8x16; #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16; + #[inline(always)] + fn compress_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16 { + self.compress_merge_u8x16(values, mask, u8x16::splat(self, 0)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u8x16( self, values: u8x16, mask: mask8x16, merge: u8x16, - ) -> u8x16; + ) -> u8x16 { + let mask = self.to_bitmask_mask8x16(mask); + let mut merge_padded = [0u8; 16 + 1]; + merge_padded[..16].copy_from_slice(&*merge); + let mut compacted = merge_padded; + let mut output_lane = 0; + for input_lane in 0..16 { + compacted[output_lane] = values[input_lane]; + output_lane += ((mask >> input_lane) & 1) as usize; + } + compacted[output_lane] = merge_padded[output_lane]; + let mut result = merge; + result.copy_from_slice(&compacted[..16]); + result + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16; + #[inline(always)] + fn expand_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16 { + self.expand_merge_u8x16(values, mask, u8x16::splat(self, 0)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u8x16( self, values: u8x16, mask: mask8x16, merge: u8x16, - ) -> u8x16; + ) -> u8x16 { + let mask = self.to_bitmask_mask8x16(mask); + let mut result = merge; + let mut input_lane = 0; + for output_lane in 0..16 { + let bit = ((mask >> output_lane) & 1) as u8; + let keep = 0u8.wrapping_sub(bit); + result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); + input_lane += usize::from(bit); + } + result + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_u8x16(self, a: u8x16) -> u8x16; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16; + #[inline(always)] + fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { + self.count_ones_u8x16(self.not_u8x16(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16; + #[inline(always)] + fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { + a + } #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16; #[doc = "Add two vectors element-wise, wrapping on overflow."] @@ -713,7 +892,10 @@ pub trait Simd: #[doc = "Compute the bitwise XOR of two vectors."] fn xor_u8x16(self, a: u8x16, b: u8x16) -> u8x16; #[doc = "Compute the bitwise NOT of the vector."] - fn not_u8x16(self, a: u8x16) -> u8x16; + #[inline(always)] + fn not_u8x16(self, a: u8x16) -> u8x16 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_u8x16(self, a: u8x16, shift: u32) -> u8x16; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -735,7 +917,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_u8x16(self, a: u8x16, b: u8x16) -> u8x16; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16; + #[inline(always)] + fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -766,11 +955,23 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_u8x16(self, a: u8x16, b: u8x16) -> u8x16; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16); + #[inline(always)] + fn interleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { + (self.zip_low_u8x16(a, b), self.zip_high_u8x16(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16); + #[inline(always)] + fn deinterleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { + (self.unzip_low_u8x16(a, b), self.unzip_high_u8x16(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_u8x16(self, a: mask8x16, b: u8x16, c: u8x16) -> u8x16; + #[inline(always)] + fn select_u8x16(self, a: mask8x16, b: u8x16, c: u8x16) -> u8x16 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_u8x16(self, a: u8x16, b: u8x16) -> u8x32; #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] @@ -786,13 +987,28 @@ pub trait Simd: #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] fn widen_u8x16(self, a: u8x16) -> (u16x8, u16x8); #[doc = "Multiply corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8); + #[inline(always)] + fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { + let (a0, a1) = self.widen_u8x16(a); + let (b0, b1) = self.widen_u8x16(b); + (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) + } #[doc = "Add corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8); + #[inline(always)] + fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { + let (a0, a1) = self.widen_u8x16(a); + let (b0, b1) = self.widen_u8x16(b); + (self.add_u16x8(a0, b0), self.add_u16x8(a1, b1)) + } #[doc = "Add adjacent integer lanes exactly into twice-wide lanes.\n\nOutput lane `i` is `widen(a[2*i]) + widen(a[2*i+1])`. The result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. The sum cannot overflow the widened type.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` produces `[3, 7, 11, 15]`. See [`SimdIntWiden::pairwise_widening_add`] for supported types and examples."] fn pairwise_widening_add_u8x16(self, a: u8x16) -> u16x8; #[doc = "Multiply corresponding integer lanes exactly in the widened type, then sum adjacent pairs of products.\n\nThe result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. Lane `i` is `widen(a[2*i]) * widen(b[2*i]) + widen(a[2*i+1]) * widen(b[2*i+1])`; addition wraps in the destination type, including in debug builds.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` and `[10, 20, 30, 40, 50, 60, 70, 80]` produce `[50, 250, 610, 1130]`. See [`SimdIntWiden::pairwise_dot_product`] for examples."] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8; + #[inline(always)] + fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { + let (low, high) = self.widening_mul_u8x16(a, b); + let (even, odd) = self.deinterleave_u16x8(low, high); + self.add_u16x8(even, odd) + } #[doc = "Create a SIMD mask with all lanes set from the given boolean value."] fn splat_mask8x16(self, val: bool) -> mask8x16; #[doc = "Create a SIMD mask from a compact bitmask.\n\nBit `i` maps to lane `i`, with lane 0 in the least significant bit. Bits above the number of lanes in this mask are ignored."] @@ -800,38 +1016,77 @@ pub trait Simd: #[doc = "Convert a SIMD mask to a compact bitmask.\n\nBit `i` maps to lane `i`, with lane 0 in the least significant bit. Bits above the number of lanes in this mask are cleared."] fn to_bitmask_mask8x16(self, a: mask8x16) -> u64; #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16; + #[inline(always)] + fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { + mask8x16 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16; + #[inline(always)] + fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { + i8x16 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask8x16( self, a: mask8x16, - ) -> mask8x16; + ) -> mask8x16 { + mask8x16::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask8x16( self, a: mask8x16, - ) -> mask8x16; + ) -> mask8x16 { + mask8x16::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16; + #[inline(always)] + fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { + mask8x16::from_vector(a.to_vector() & b.to_vector()) + } #[doc = "Compute the logical OR of two masks."] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16; + #[inline(always)] + fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { + mask8x16::from_vector(a.to_vector() | b.to_vector()) + } #[doc = "Compute the logical XOR of two masks."] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16; + #[inline(always)] + fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { + mask8x16::from_vector(a.to_vector() ^ b.to_vector()) + } #[doc = "Compute the logical NOT of the mask."] - fn not_mask8x16(self, a: mask8x16) -> mask8x16; + #[inline(always)] + fn not_mask8x16(self, a: mask8x16) -> mask8x16 { + mask8x16::from_vector(!a.to_vector()) + } #[doc = "Reverse the order of the mask's logical lanes."] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16; + #[inline(always)] + fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { + mask8x16::from_vector(a.to_vector().reverse()) + } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] + #[inline(always)] fn select_mask8x16( self, a: mask8x16, b: mask8x16, c: mask8x16, - ) -> mask8x16; + ) -> mask8x16 { + let mask = a.to_vector(); + let b = b.to_vector(); + let c = c.to_vector(); + mask8x16::from_vector((mask & b) | (!mask & c)) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16; #[doc = "Compare two masks element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -912,27 +1167,54 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8; + #[inline(always)] + fn compress_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i16x8( self, values: i16x8, mask: mask16x8, merge: i16x8, - ) -> i16x8; + ) -> i16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8; + #[inline(always)] + fn expand_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i16x8( self, values: i16x8, mask: mask16x8, merge: i16x8, - ) -> i16x8; + ) -> i16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_i16x8(self, a: i16x8) -> i16x8; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8; + #[inline(always)] + fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { + self.count_ones_i16x8(self.not_i16x8(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8; #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] @@ -948,13 +1230,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_i16x8(self, a: i16x8, b: i16x8) -> i16x8; #[doc = "Compute the bitwise AND of two vectors."] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8; + #[inline(always)] + fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8; + #[inline(always)] + fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8; + #[inline(always)] + fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_i16x8(self, a: i16x8) -> i16x8; + #[inline(always)] + fn not_i16x8(self, a: i16x8) -> i16x8 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_i16x8(self, a: i16x8, shift: u32) -> i16x8; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -976,7 +1270,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_i16x8(self, a: i16x8, b: i16x8) -> i16x8; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8; + #[inline(always)] + fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -1007,15 +1308,30 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_i16x8(self, a: i16x8, b: i16x8) -> i16x8; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8); + #[inline(always)] + fn interleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { + (self.zip_low_i16x8(a, b), self.zip_high_i16x8(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8); + #[inline(always)] + fn deinterleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { + (self.unzip_low_i16x8(a, b), self.unzip_high_i16x8(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_i16x8(self, a: mask16x8, b: i16x8, c: i16x8) -> i16x8; + #[inline(always)] + fn select_i16x8(self, a: mask16x8, b: i16x8, c: i16x8) -> i16x8 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_i16x8(self, a: i16x8, b: i16x8) -> i16x16; #[doc = "Negate each element of the vector, wrapping on overflow."] - fn neg_i16x8(self, a: i16x8) -> i16x8; + #[inline(always)] + fn neg_i16x8(self, a: i16x8) -> i16x8 { + self.sub_i16x8(self.splat_i16x8(0), a) + } #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] #[doc(alias = "load_interleaved")] fn load_four_interleaved_i16x8(self, src: &[i16; 32usize]) -> [i16x8; 4usize]; @@ -1029,13 +1345,28 @@ pub trait Simd: #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] fn widen_i16x8(self, a: i16x8) -> (i32x4, i32x4); #[doc = "Multiply corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_mul_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4); + #[inline(always)] + fn widening_mul_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { + let (a0, a1) = self.widen_i16x8(a); + let (b0, b1) = self.widen_i16x8(b); + (self.mul_i32x4(a0, b0), self.mul_i32x4(a1, b1)) + } #[doc = "Add corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_add_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4); + #[inline(always)] + fn widening_add_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { + let (a0, a1) = self.widen_i16x8(a); + let (b0, b1) = self.widen_i16x8(b); + (self.add_i32x4(a0, b0), self.add_i32x4(a1, b1)) + } #[doc = "Add adjacent integer lanes exactly into twice-wide lanes.\n\nOutput lane `i` is `widen(a[2*i]) + widen(a[2*i+1])`. The result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. The sum cannot overflow the widened type.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` produces `[3, 7, 11, 15]`. See [`SimdIntWiden::pairwise_widening_add`] for supported types and examples."] fn pairwise_widening_add_i16x8(self, a: i16x8) -> i32x4; #[doc = "Multiply corresponding integer lanes exactly in the widened type, then sum adjacent pairs of products.\n\nThe result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. Lane `i` is `widen(a[2*i]) * widen(b[2*i]) + widen(a[2*i+1]) * widen(b[2*i+1])`; addition wraps in the destination type, including in debug builds.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` and `[10, 20, 30, 40, 50, 60, 70, 80]` produce `[50, 250, 610, 1130]`. See [`SimdIntWiden::pairwise_dot_product`] for examples."] - fn pairwise_dot_product_i16x8(self, a: i16x8, b: i16x8) -> i32x4; + #[inline(always)] + fn pairwise_dot_product_i16x8(self, a: i16x8, b: i16x8) -> i32x4 { + let (low, high) = self.widening_mul_i16x8(a, b); + let (even, odd) = self.deinterleave_i32x4(low, high); + self.add_i32x4(even, odd) + } #[doc = "Truncate the lanes of two vectors and concatenate them into one same-width vector.\n\nEach lane retains its low destination-width bits. `a` provides the lower result lanes and `b` provides the upper result lanes."] fn narrow_i16x8(self, a: i16x8, b: i16x8) -> i8x16; #[doc = "Narrow the lanes of two vectors with saturation and concatenate them into one same-width vector.\n\nEach lane is clamped to the destination type's range. `a` provides the lower result lanes and `b` provides the upper result lanes."] @@ -1106,27 +1437,54 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8; + #[inline(always)] + fn compress_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u16x8( self, values: u16x8, mask: mask16x8, merge: u16x8, - ) -> u16x8; + ) -> u16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8; + #[inline(always)] + fn expand_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u16x8( self, values: u16x8, mask: mask16x8, merge: u16x8, - ) -> u16x8; + ) -> u16x8 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_u16x8(self, a: u16x8) -> u16x8; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8; + #[inline(always)] + fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { + self.count_ones_u16x8(self.not_u16x8(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8; #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] @@ -1142,13 +1500,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_u16x8(self, a: u16x8, b: u16x8) -> u16x8; #[doc = "Compute the bitwise AND of two vectors."] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8; + #[inline(always)] + fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8; + #[inline(always)] + fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8; + #[inline(always)] + fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_u16x8(self, a: u16x8) -> u16x8; + #[inline(always)] + fn not_u16x8(self, a: u16x8) -> u16x8 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -1170,7 +1540,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_u16x8(self, a: u16x8, b: u16x8) -> u16x8; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8; + #[inline(always)] + fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -1201,11 +1578,23 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_u16x8(self, a: u16x8, b: u16x8) -> u16x8; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8); + #[inline(always)] + fn interleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { + (self.zip_low_u16x8(a, b), self.zip_high_u16x8(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8); + #[inline(always)] + fn deinterleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { + (self.unzip_low_u16x8(a, b), self.unzip_high_u16x8(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_u16x8(self, a: mask16x8, b: u16x8, c: u16x8) -> u16x8; + #[inline(always)] + fn select_u16x8(self, a: mask16x8, b: u16x8, c: u16x8) -> u16x8 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_u16x8(self, a: u16x8, b: u16x8) -> u16x16; #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] @@ -1221,13 +1610,28 @@ pub trait Simd: #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] fn widen_u16x8(self, a: u16x8) -> (u32x4, u32x4); #[doc = "Multiply corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_mul_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4); + #[inline(always)] + fn widening_mul_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { + let (a0, a1) = self.widen_u16x8(a); + let (b0, b1) = self.widen_u16x8(b); + (self.mul_u32x4(a0, b0), self.mul_u32x4(a1, b1)) + } #[doc = "Add corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4); + #[inline(always)] + fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { + let (a0, a1) = self.widen_u16x8(a); + let (b0, b1) = self.widen_u16x8(b); + (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) + } #[doc = "Add adjacent integer lanes exactly into twice-wide lanes.\n\nOutput lane `i` is `widen(a[2*i]) + widen(a[2*i+1])`. The result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. The sum cannot overflow the widened type.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` produces `[3, 7, 11, 15]`. See [`SimdIntWiden::pairwise_widening_add`] for supported types and examples."] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4; #[doc = "Multiply corresponding integer lanes exactly in the widened type, then sum adjacent pairs of products.\n\nThe result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. Lane `i` is `widen(a[2*i]) * widen(b[2*i]) + widen(a[2*i+1]) * widen(b[2*i+1])`; addition wraps in the destination type, including in debug builds.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` and `[10, 20, 30, 40, 50, 60, 70, 80]` produce `[50, 250, 610, 1130]`. See [`SimdIntWiden::pairwise_dot_product`] for examples."] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4; + #[inline(always)] + fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { + let (low, high) = self.widening_mul_u16x8(a, b); + let (even, odd) = self.deinterleave_u32x4(low, high); + self.add_u32x4(even, odd) + } #[doc = "Truncate the lanes of two vectors and concatenate them into one same-width vector.\n\nEach lane retains its low destination-width bits. `a` provides the lower result lanes and `b` provides the upper result lanes."] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16; #[doc = "Narrow the lanes of two vectors with saturation and concatenate them into one same-width vector.\n\nEach lane is clamped to the destination type's range. `a` provides the lower result lanes and `b` provides the upper result lanes."] @@ -1241,38 +1645,77 @@ pub trait Simd: #[doc = "Convert a SIMD mask to a compact bitmask.\n\nBit `i` maps to lane `i`, with lane 0 in the least significant bit. Bits above the number of lanes in this mask are cleared."] fn to_bitmask_mask16x8(self, a: mask16x8) -> u64; #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8; + #[inline(always)] + fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { + mask16x8 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8; + #[inline(always)] + fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { + i16x8 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask16x8( self, a: mask16x8, - ) -> mask16x8; + ) -> mask16x8 { + mask16x8::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask16x8( self, a: mask16x8, - ) -> mask16x8; + ) -> mask16x8 { + mask16x8::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8; + #[inline(always)] + fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + mask16x8::from_vector(a.to_vector() & b.to_vector()) + } #[doc = "Compute the logical OR of two masks."] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8; + #[inline(always)] + fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + mask16x8::from_vector(a.to_vector() | b.to_vector()) + } #[doc = "Compute the logical XOR of two masks."] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8; + #[inline(always)] + fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { + mask16x8::from_vector(a.to_vector() ^ b.to_vector()) + } #[doc = "Compute the logical NOT of the mask."] - fn not_mask16x8(self, a: mask16x8) -> mask16x8; + #[inline(always)] + fn not_mask16x8(self, a: mask16x8) -> mask16x8 { + mask16x8::from_vector(!a.to_vector()) + } #[doc = "Reverse the order of the mask's logical lanes."] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8; + #[inline(always)] + fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { + mask16x8::from_vector(a.to_vector().reverse()) + } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] + #[inline(always)] fn select_mask16x8( self, a: mask16x8, b: mask16x8, c: mask16x8, - ) -> mask16x8; + ) -> mask16x8 { + let mask = a.to_vector(); + let b = b.to_vector(); + let c = c.to_vector(); + mask16x8::from_vector((mask & b) | (!mask & c)) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8; #[doc = "Compare two masks element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -1355,27 +1798,54 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4; + #[inline(always)] + fn compress_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i32x4( self, values: i32x4, mask: mask32x4, merge: i32x4, - ) -> i32x4; + ) -> i32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4; + #[inline(always)] + fn expand_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i32x4( self, values: i32x4, mask: mask32x4, merge: i32x4, - ) -> i32x4; + ) -> i32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_i32x4(self, a: i32x4) -> i32x4; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4; + #[inline(always)] + fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { + self.count_ones_i32x4(self.not_i32x4(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4; #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] @@ -1391,13 +1861,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_i32x4(self, a: i32x4, b: i32x4) -> i32x4; #[doc = "Compute the bitwise AND of two vectors."] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4; + #[inline(always)] + fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4; + #[inline(always)] + fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4; + #[inline(always)] + fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_i32x4(self, a: i32x4) -> i32x4; + #[inline(always)] + fn not_i32x4(self, a: i32x4) -> i32x4 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_i32x4(self, a: i32x4, shift: u32) -> i32x4; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -1419,7 +1901,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_i32x4(self, a: i32x4, b: i32x4) -> i32x4; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4; + #[inline(always)] + fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -1450,15 +1939,30 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_i32x4(self, a: i32x4, b: i32x4) -> i32x4; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4); + #[inline(always)] + fn interleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { + (self.zip_low_i32x4(a, b), self.zip_high_i32x4(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4); + #[inline(always)] + fn deinterleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { + (self.unzip_low_i32x4(a, b), self.unzip_high_i32x4(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_i32x4(self, a: mask32x4, b: i32x4, c: i32x4) -> i32x4; + #[inline(always)] + fn select_i32x4(self, a: mask32x4, b: i32x4, c: i32x4) -> i32x4 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_i32x4(self, a: i32x4, b: i32x4) -> i32x8; #[doc = "Negate each element of the vector, wrapping on overflow."] - fn neg_i32x4(self, a: i32x4) -> i32x4; + #[inline(always)] + fn neg_i32x4(self, a: i32x4) -> i32x4 { + self.sub_i32x4(self.splat_i32x4(0), a) + } #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] #[doc(alias = "load_interleaved")] fn load_four_interleaved_i32x4(self, src: &[i32; 16usize]) -> [i32x4; 4usize]; @@ -1472,13 +1976,28 @@ pub trait Simd: #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] fn widen_i32x4(self, a: i32x4) -> (i64x2, i64x2); #[doc = "Multiply corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_mul_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2); + #[inline(always)] + fn widening_mul_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { + let (a0, a1) = self.widen_i32x4(a); + let (b0, b1) = self.widen_i32x4(b); + (self.mul_i64x2(a0, b0), self.mul_i64x2(a1, b1)) + } #[doc = "Add corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2); + #[inline(always)] + fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { + let (a0, a1) = self.widen_i32x4(a); + let (b0, b1) = self.widen_i32x4(b); + (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) + } #[doc = "Add adjacent integer lanes exactly into twice-wide lanes.\n\nOutput lane `i` is `widen(a[2*i]) + widen(a[2*i+1])`. The result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. The sum cannot overflow the widened type.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` produces `[3, 7, 11, 15]`. See [`SimdIntWiden::pairwise_widening_add`] for supported types and examples."] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2; #[doc = "Multiply corresponding integer lanes exactly in the widened type, then sum adjacent pairs of products.\n\nThe result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. Lane `i` is `widen(a[2*i]) * widen(b[2*i]) + widen(a[2*i+1]) * widen(b[2*i+1])`; addition wraps in the destination type, including in debug builds.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` and `[10, 20, 30, 40, 50, 60, 70, 80]` produce `[50, 250, 610, 1130]`. See [`SimdIntWiden::pairwise_dot_product`] for examples."] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2; + #[inline(always)] + fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { + let (low, high) = self.widening_mul_i32x4(a, b); + let (even, odd) = self.deinterleave_i64x2(low, high); + self.add_i64x2(even, odd) + } #[doc = "Truncate the lanes of two vectors and concatenate them into one same-width vector.\n\nEach lane retains its low destination-width bits. `a` provides the lower result lanes and `b` provides the upper result lanes."] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8; #[doc = "Narrow the lanes of two vectors with saturation and concatenate them into one same-width vector.\n\nEach lane is clamped to the destination type's range. `a` provides the lower result lanes and `b` provides the upper result lanes."] @@ -1551,27 +2070,54 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4; + #[inline(always)] + fn compress_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u32x4( self, values: u32x4, mask: mask32x4, merge: u32x4, - ) -> u32x4; + ) -> u32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4; + #[inline(always)] + fn expand_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u32x4( self, values: u32x4, mask: mask32x4, merge: u32x4, - ) -> u32x4; + ) -> u32x4 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_u32x4(self, a: u32x4) -> u32x4; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4; + #[inline(always)] + fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { + self.count_ones_u32x4(self.not_u32x4(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4; #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] @@ -1587,13 +2133,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_u32x4(self, a: u32x4, b: u32x4) -> u32x4; #[doc = "Compute the bitwise AND of two vectors."] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4; + #[inline(always)] + fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4; + #[inline(always)] + fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4; + #[inline(always)] + fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_u32x4(self, a: u32x4) -> u32x4; + #[inline(always)] + fn not_u32x4(self, a: u32x4) -> u32x4 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_u32x4(self, a: u32x4, shift: u32) -> u32x4; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -1615,7 +2173,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_u32x4(self, a: u32x4, b: u32x4) -> u32x4; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4; + #[inline(always)] + fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -1646,11 +2211,23 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_u32x4(self, a: u32x4, b: u32x4) -> u32x4; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4); + #[inline(always)] + fn interleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { + (self.zip_low_u32x4(a, b), self.zip_high_u32x4(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4); + #[inline(always)] + fn deinterleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { + (self.unzip_low_u32x4(a, b), self.unzip_high_u32x4(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_u32x4(self, a: mask32x4, b: u32x4, c: u32x4) -> u32x4; + #[inline(always)] + fn select_u32x4(self, a: mask32x4, b: u32x4, c: u32x4) -> u32x4 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_u32x4(self, a: u32x4, b: u32x4) -> u32x8; #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] @@ -1666,13 +2243,28 @@ pub trait Simd: #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] fn widen_u32x4(self, a: u32x4) -> (u64x2, u64x2); #[doc = "Multiply corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2); + #[inline(always)] + fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { + let (a0, a1) = self.widen_u32x4(a); + let (b0, b1) = self.widen_u32x4(b); + (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) + } #[doc = "Add corresponding integer lanes exactly into twice-wide lanes. The first result contains the lower lanes and the second contains the upper lanes."] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2); + #[inline(always)] + fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { + let (a0, a1) = self.widen_u32x4(a); + let (b0, b1) = self.widen_u32x4(b); + (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) + } #[doc = "Add adjacent integer lanes exactly into twice-wide lanes.\n\nOutput lane `i` is `widen(a[2*i]) + widen(a[2*i+1])`. The result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. The sum cannot overflow the widened type.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` produces `[3, 7, 11, 15]`. See [`SimdIntWiden::pairwise_widening_add`] for supported types and examples."] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2; #[doc = "Multiply corresponding integer lanes exactly in the widened type, then sum adjacent pairs of products.\n\nThe result has half as many lanes, twice the lane width, and unchanged signedness and total bit width. Lane `i` is `widen(a[2*i]) * widen(b[2*i]) + widen(a[2*i+1]) * widen(b[2*i+1])`; addition wraps in the destination type, including in debug builds.\n\nFor example, `[1, 2, 3, 4, 5, 6, 7, 8]` and `[10, 20, 30, 40, 50, 60, 70, 80]` produce `[50, 250, 610, 1130]`. See [`SimdIntWiden::pairwise_dot_product`] for examples."] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2; + #[inline(always)] + fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { + let (low, high) = self.widening_mul_u32x4(a, b); + let (even, odd) = self.deinterleave_u64x2(low, high); + self.add_u64x2(even, odd) + } #[doc = "Truncate the lanes of two vectors and concatenate them into one same-width vector.\n\nEach lane retains its low destination-width bits. `a` provides the lower result lanes and `b` provides the upper result lanes."] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8; #[doc = "Narrow the lanes of two vectors with saturation and concatenate them into one same-width vector.\n\nEach lane is clamped to the destination type's range. `a` provides the lower result lanes and `b` provides the upper result lanes."] @@ -1688,38 +2280,77 @@ pub trait Simd: #[doc = "Convert a SIMD mask to a compact bitmask.\n\nBit `i` maps to lane `i`, with lane 0 in the least significant bit. Bits above the number of lanes in this mask are cleared."] fn to_bitmask_mask32x4(self, a: mask32x4) -> u64; #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4; + #[inline(always)] + fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { + mask32x4 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4; + #[inline(always)] + fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { + i32x4 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask32x4( self, a: mask32x4, - ) -> mask32x4; + ) -> mask32x4 { + mask32x4::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask32x4( self, a: mask32x4, - ) -> mask32x4; + ) -> mask32x4 { + mask32x4::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4; + #[inline(always)] + fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { + mask32x4::from_vector(a.to_vector() & b.to_vector()) + } #[doc = "Compute the logical OR of two masks."] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4; + #[inline(always)] + fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { + mask32x4::from_vector(a.to_vector() | b.to_vector()) + } #[doc = "Compute the logical XOR of two masks."] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4; + #[inline(always)] + fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { + mask32x4::from_vector(a.to_vector() ^ b.to_vector()) + } #[doc = "Compute the logical NOT of the mask."] - fn not_mask32x4(self, a: mask32x4) -> mask32x4; + #[inline(always)] + fn not_mask32x4(self, a: mask32x4) -> mask32x4 { + mask32x4::from_vector(!a.to_vector()) + } #[doc = "Reverse the order of the mask's logical lanes."] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4; + #[inline(always)] + fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { + mask32x4::from_vector(a.to_vector().reverse()) + } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] + #[inline(always)] fn select_mask32x4( self, a: mask32x4, b: mask32x4, c: mask32x4, - ) -> mask32x4; + ) -> mask32x4 { + let mask = a.to_vector(); + let b = b.to_vector(); + let c = c.to_vector(); + mask32x4::from_vector((mask & b) | (!mask & c)) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4; #[doc = "Compare two masks element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -1802,23 +2433,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2; + #[inline(always)] + fn compress_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_f64x2( self, values: f64x2, mask: mask64x2, merge: f64x2, - ) -> f64x2; + ) -> f64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2; + #[inline(always)] + fn expand_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_f64x2( self, values: f64x2, mask: mask64x2, merge: f64x2, - ) -> f64x2; + ) -> f64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Negate each element of the vector."] fn neg_f64x2(self, a: f64x2) -> f64x2; #[doc = "Compute the square root of each element.\n\nNegative elements other than `-0.0` will become NaN."] @@ -1887,9 +2542,15 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_f64x2(self, a: f64x2, b: f64x2) -> f64x2; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2); + #[inline(always)] + fn interleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { + (self.zip_low_f64x2(a, b), self.zip_high_f64x2(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2); + #[inline(always)] + fn deinterleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { + (self.unzip_low_f64x2(a, b), self.unzip_high_f64x2(a, b)) + } #[doc = "Compute `(a * b) + c` (potentially fused multiply-add) for each element.\n\nThe result may be computed with one or two rounding errors depending on which can be computed faster on the current platform."] fn mul_add_f64x2(self, a: f64x2, b: f64x2, c: f64x2) -> f64x2; #[doc = "Compute `(a * b) + c` for each element, with a single rounding at the end.\n\nThe result is the infinite-precision product-plus-add rounded once to the element type. This may be substantially slower than `mul_add` on platforms without fused multiply-add instructions, including WebAssembly.\n\n# Precision guarantees\n\nThis function is **not** susceptible to [the bug](https://github.com/rust-lang/compiler-builtins/issues/1262) in Rust standard library and in musl libc that causes incorrect rounding for near-zero values on CPUs without hardware support for this operation.\n\nOn the tier-2 i586-* targets, this function is correct if and only if SSE2 is available on the CPU.\n\nThe exact `NaN` payloads as well as signaling `NaN`s are not preserved.\n\n# Performance\n\nThe following platforms will use a single fused multiply-add instruction for this operation: ARM NEON, x86 AVX2, and x86 AVX512."] @@ -1915,21 +2576,52 @@ pub trait Simd: #[doc = "Converts degrees to radians.\n\nThe precision of this function is non-deterministic. This means it varies by platform, Rust version, and can even differ within the same execution from one invocation to the next."] fn to_radians_f64x2(self, a: f64x2) -> f64x2; #[doc = "Return a mask indicating which elements are NaN."] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { + a.simd_ne(a) + } #[doc = "Return a mask indicating which elements are positive or negative infinite."] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { + a.abs().simd_eq(f64::INFINITY) + } #[doc = "Return a mask indicating which elements are neither infinite nor NaN."] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { + a.abs().simd_lt(f64::INFINITY) + } #[doc = "Return a mask indicating which elements are subnormal.\n\nThis classifies the stored bit pattern, even when floating-point operations treat subnormals as zero."] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { + let i: i64x2 = a.bitcast(); + (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) + } #[doc = "Return a mask indicating which elements are neither zero, infinite, subnormal, or NaN."] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { + let i: i64x2 = a.bitcast(); + let exp = i & 0x7FF0_0000_0000_0000_i64; + exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) + } #[doc = "Return a mask indicating which elements have a positive sign, including `+0.0`, NaNs with positive sign bit and positive infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_positive`] for details."] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { + let i: i64x2 = a.bitcast(); + (i & i64::MIN).simd_eq(0) + } #[doc = "Return a mask indicating which elements have a negative sign, including `-0.0`, NaNs with negative sign bit and negative infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_negative`] for details."] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2; + #[inline(always)] + fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { + !a.is_sign_positive() + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2; + #[inline(always)] + fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_f64x2(self, a: f64x2, b: f64x2) -> f64x4; #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] @@ -2017,27 +2709,54 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2; + #[inline(always)] + fn compress_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i64x2( self, values: i64x2, mask: mask64x2, merge: i64x2, - ) -> i64x2; + ) -> i64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2; + #[inline(always)] + fn expand_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i64x2( self, values: i64x2, mask: mask64x2, merge: i64x2, - ) -> i64x2; + ) -> i64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_i64x2(self, a: i64x2) -> i64x2; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2; + #[inline(always)] + fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { + self.count_ones_i64x2(self.not_i64x2(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2; #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] @@ -2053,13 +2772,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_i64x2(self, a: i64x2, b: i64x2) -> i64x2; #[doc = "Compute the bitwise AND of two vectors."] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2; + #[inline(always)] + fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2; + #[inline(always)] + fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2; + #[inline(always)] + fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_i64x2(self, a: i64x2) -> i64x2; + #[inline(always)] + fn not_i64x2(self, a: i64x2) -> i64x2 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_i64x2(self, a: i64x2, shift: u32) -> i64x2; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -2081,7 +2812,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_i64x2(self, a: i64x2, b: i64x2) -> i64x2; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2; + #[inline(always)] + fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -2112,15 +2850,30 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_i64x2(self, a: i64x2, b: i64x2) -> i64x2; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2); + #[inline(always)] + fn interleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { + (self.zip_low_i64x2(a, b), self.zip_high_i64x2(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2); + #[inline(always)] + fn deinterleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { + (self.unzip_low_i64x2(a, b), self.unzip_high_i64x2(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_i64x2(self, a: mask64x2, b: i64x2, c: i64x2) -> i64x2; + #[inline(always)] + fn select_i64x2(self, a: mask64x2, b: i64x2, c: i64x2) -> i64x2 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_i64x2(self, a: i64x2, b: i64x2) -> i64x4; #[doc = "Negate each element of the vector, wrapping on overflow."] - fn neg_i64x2(self, a: i64x2) -> i64x2; + #[inline(always)] + fn neg_i64x2(self, a: i64x2) -> i64x2 { + self.sub_i64x2(self.splat_i64x2(0), a) + } #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] #[doc(alias = "load_interleaved")] fn load_four_interleaved_i64x2(self, src: &[i64; 8usize]) -> [i64x2; 4usize]; @@ -2203,27 +2956,54 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2; + #[inline(always)] + fn compress_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u64x2( self, values: u64x2, mask: mask64x2, merge: u64x2, - ) -> u64x2; + ) -> u64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2; + #[inline(always)] + fn expand_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u64x2( self, values: u64x2, mask: mask64x2, merge: u64x2, - ) -> u64x2; + ) -> u64x2 { + let mask = mask8x16::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x16( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] fn count_ones_u64x2(self, a: u64x2) -> u64x2; #[doc = "Return the number of zeros in the binary representation of each element."] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2; + #[inline(always)] + fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { + self.count_ones_u64x2(self.not_u64x2(a)) + } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2; #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] @@ -2239,13 +3019,25 @@ pub trait Simd: #[doc = "Multiply two vectors element-wise, wrapping on overflow."] fn mul_u64x2(self, a: u64x2, b: u64x2) -> u64x2; #[doc = "Compute the bitwise AND of two vectors."] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2; + #[inline(always)] + fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { + Bytes::from_bytes(self.and_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise OR of two vectors."] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2; + #[inline(always)] + fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { + Bytes::from_bytes(self.or_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise XOR of two vectors."] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2; + #[inline(always)] + fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { + Bytes::from_bytes(self.xor_u8x16(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } #[doc = "Compute the bitwise NOT of the vector."] - fn not_u64x2(self, a: u64x2) -> u64x2; + #[inline(always)] + fn not_u64x2(self, a: u64x2) -> u64x2 { + a ^ !0 + } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] fn shl_u64x2(self, a: u64x2, shift: u32) -> u64x2; #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform.\n\n# Performance\nThis per-lane shift is slower than shifting the entire vector by a scalar. It is not vectorized at all on WebAssembly, SSE4.2, and for `u8` and `i8` elements on AVX2. Prefer shifting by a single scalar value instead of by a vector whenever possible."] @@ -2267,7 +3059,14 @@ pub trait Simd: #[doc = "Return the element-wise minimum of two vectors.\n\nFor floating-point vectors, if either operand is NaN, the result for that lane is implementation-defined-- it could be either the first or second operand. See `min_precise` for a version that returns the non-NaN operand if only one is NaN.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is also implementation-defined, and it could be either one."] fn min_u64x2(self, a: u64x2, b: u64x2) -> u64x2; #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2; + #[inline(always)] + fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2; #[doc = "Compare two vectors element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nFor floating-point vectors, this follows Rust's `!=` semantics: a lane is true if either operand is NaN, including when both are NaN. Positive and negative zero compare equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -2298,11 +3097,23 @@ pub trait Simd: #[doc = "Extract odd-indexed elements from two vectors.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `[a1, a3, b1, b3]`.\n\n**Note:** This operation is only useful if you need to discard elements `a0, a2, b0, b2`.For fully deinterleaving two vectors prefer `deinterleave`,\n which is faster than `unzip_low` followed by `unzip_high` on some platforms."] fn unzip_high_u64x2(self, a: u64x2, b: u64x2) -> u64x2; #[doc = "Interleave two vectors.\n\nThe resulting vectors contain elements taken alternately from `a` and `b`, first filling the first result, and then the second.\n\nThe reverse of this operation is `deinterleave`.\n\nFor vectors `[a0, a1, a2, a3]` and `[b0, b1, b2, b3]`, returns `([a0, b0, a1, b1], [a2, b2, a3, b3])`."] - fn interleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2); + #[inline(always)] + fn interleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { + (self.zip_low_u64x2(a, b), self.zip_high_u64x2(a, b)) + } #[doc = "Deinterleave two vectors.\n\nThe first result contains all even-indexed elements from `a` followed by all even-indexed elements from `b`. The second result contains all odd-indexed elements from `a` followed by all odd-indexed elements from `b`.\n\nThe reverse of this operation is `interleave`.\n\nFor vectors `[a0, b0, a1, b1]` and `[a2, b2, a3, b3]`, returns `([a0, a1, a2, a3], [b0, b1, b2, b3])`."] - fn deinterleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2); + #[inline(always)] + fn deinterleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { + (self.unzip_low_u64x2(a, b), self.unzip_high_u64x2(a, b)) + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] - fn select_u64x2(self, a: mask64x2, b: u64x2, c: u64x2) -> u64x2; + #[inline(always)] + fn select_u64x2(self, a: mask64x2, b: u64x2, c: u64x2) -> u64x2 { + let mask = a.to_vector(); + let b = b.bitcast::>(); + let c = c.bitcast::>(); + ((mask & b) | (!mask & c)).bitcast() + } #[doc = "Combine two vectors into a single vector with twice the width.\n\n`a` provides the lower elements and `b` provides the upper elements."] fn combine_u64x2(self, a: u64x2, b: u64x2) -> u64x4; #[doc = "Load four 128-bit vectors from an array with 4-way interleaving.\n\nThis is useful e.g. in image processing to turn interleaved RGBA pixels into vectors of each color component.\n\nFor example, with 32-bit lanes, memory laid out as`[r0, g0, b0, a0, r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3]` loads as`[[r0, r1, r2, r3], [g0, g1, g2, g3], [b0, b1, b2, b3], [a0, a1, a2, a3]]`."] @@ -2330,38 +3141,77 @@ pub trait Simd: #[doc = "Convert a SIMD mask to a compact bitmask.\n\nBit `i` maps to lane `i`, with lane 0 in the least significant bit. Bits above the number of lanes in this mask are cleared."] fn to_bitmask_mask64x2(self, a: mask64x2) -> u64; #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2; + #[inline(always)] + fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { + mask64x2 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2; + #[inline(always)] + fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { + i64x2 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask64x2( self, a: mask64x2, - ) -> mask64x2; + ) -> mask64x2 { + mask64x2::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask64x2( self, a: mask64x2, - ) -> mask64x2; + ) -> mask64x2 { + mask64x2::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2; + #[inline(always)] + fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { + mask64x2::from_vector(a.to_vector() & b.to_vector()) + } #[doc = "Compute the logical OR of two masks."] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2; + #[inline(always)] + fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { + mask64x2::from_vector(a.to_vector() | b.to_vector()) + } #[doc = "Compute the logical XOR of two masks."] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2; + #[inline(always)] + fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { + mask64x2::from_vector(a.to_vector() ^ b.to_vector()) + } #[doc = "Compute the logical NOT of the mask."] - fn not_mask64x2(self, a: mask64x2) -> mask64x2; + #[inline(always)] + fn not_mask64x2(self, a: mask64x2) -> mask64x2 { + mask64x2::from_vector(!a.to_vector()) + } #[doc = "Reverse the order of the mask's logical lanes."] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2; + #[inline(always)] + fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { + mask64x2::from_vector(a.to_vector().reverse()) + } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] + #[inline(always)] fn select_mask64x2( self, a: mask64x2, b: mask64x2, c: mask64x2, - ) -> mask64x2; + ) -> mask64x2 { + let mask = a.to_vector(); + let b = b.to_vector(); + let c = c.to_vector(); + mask64x2::from_vector((mask & b) | (!mask & c)) + } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] fn simd_eq_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2; #[doc = "Compare two masks element-wise for inequality.\n\nReturns a mask where each logical lane is true if the corresponding elements are unequal, and false if equal.\n\nThis is equivalent to negating the mask returned by `simd_eq`."] @@ -2459,23 +3309,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8; + #[inline(always)] + fn compress_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_f32x8( self, values: f32x8, mask: mask32x8, merge: f32x8, - ) -> f32x8; + ) -> f32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8; + #[inline(always)] + fn expand_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_f32x8( self, values: f32x8, mask: mask32x8, merge: f32x8, - ) -> f32x8; + ) -> f32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Negate each element of the vector."] #[inline(always)] fn neg_f32x8(self, a: f32x8) -> f32x8 { @@ -2798,19 +3672,44 @@ pub trait Simd: self.combine_f32x4(self.to_radians_f32x4(a0), self.to_radians_f32x4(a1)) } #[doc = "Return a mask indicating which elements are NaN."] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { + a.simd_ne(a) + } #[doc = "Return a mask indicating which elements are positive or negative infinite."] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { + a.abs().simd_eq(f32::INFINITY) + } #[doc = "Return a mask indicating which elements are neither infinite nor NaN."] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { + a.abs().simd_lt(f32::INFINITY) + } #[doc = "Return a mask indicating which elements are subnormal.\n\nThis classifies the stored bit pattern, even when floating-point operations treat subnormals as zero."] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { + let i: i32x8 = a.bitcast(); + (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) + } #[doc = "Return a mask indicating which elements are neither zero, infinite, subnormal, or NaN."] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { + let i: i32x8 = a.bitcast(); + let exp = i & 0x7F80_0000_i32; + exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) + } #[doc = "Return a mask indicating which elements have a positive sign, including `+0.0`, NaNs with positive sign bit and positive infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_positive`] for details."] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { + let i: i32x8 = a.bitcast(); + (i & i32::MIN).simd_eq(0) + } #[doc = "Return a mask indicating which elements have a negative sign, including `-0.0`, NaNs with negative sign bit and negative infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_negative`] for details."] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8; + #[inline(always)] + fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { + !a.is_sign_positive() + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] fn select_f32x8(self, a: mask32x8, b: f32x8, c: f32x8) -> f32x8 { @@ -2939,23 +3838,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32; + #[inline(always)] + fn compress_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i8x32( self, values: i8x32, mask: mask8x32, merge: i8x32, - ) -> i8x32; + ) -> i8x32 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32; + #[inline(always)] + fn expand_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i8x32( self, values: i8x32, mask: mask8x32, merge: i8x32, - ) -> i8x32; + ) -> i8x32 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i8x32(self, a: i8x32) -> i8x32 { @@ -2965,14 +3888,12 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i8x32(self, a: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - self.combine_i8x16(self.count_zeros_i8x16(a0), self.count_zeros_i8x16(a1)) + self.count_ones_i8x32(self.not_i8x32(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] fn swap_bytes_i8x32(self, a: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - self.combine_i8x16(self.swap_bytes_i8x16(a0), self.swap_bytes_i8x16(a1)) + a } #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] #[inline(always)] @@ -3024,29 +3945,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - let (b0, b1) = self.split_i8x32(b); - self.combine_i8x16(self.and_i8x16(a0, b0), self.and_i8x16(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - let (b0, b1) = self.split_i8x32(b); - self.combine_i8x16(self.or_i8x16(a0, b0), self.or_i8x16(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i8x32(self, a: i8x32, b: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - let (b0, b1) = self.split_i8x32(b); - self.combine_i8x16(self.xor_i8x16(a0, b0), self.xor_i8x16(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i8x32(self, a: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - self.combine_i8x16(self.not_i8x16(a0), self.not_i8x16(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -3115,10 +4029,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i8x32(self, a: i8x32, b: i8x32, c: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - let (b0, b1) = self.split_i8x32(b); - let (c0, c1) = self.split_i8x32(c); - self.combine_i8x16(self.clamp_i8x16(a0, b0, c0), self.clamp_i8x16(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -3227,8 +4142,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i8x32(self, a: i8x32) -> i8x32 { - let (a0, a1) = self.split_i8x32(a); - self.combine_i8x16(self.neg_i8x16(a0), self.neg_i8x16(a1)) + self.sub_i8x32(self.splat_i8x32(0), a) } #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] #[inline(always)] @@ -3343,23 +4257,56 @@ pub trait Simd: indices: u8x32, ) -> u8x32; #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32; + #[inline(always)] + fn compress_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32 { + self.compress_merge_u8x32(values, mask, u8x32::splat(self, 0)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u8x32( self, values: u8x32, mask: mask8x32, merge: u8x32, - ) -> u8x32; + ) -> u8x32 { + let mask = self.to_bitmask_mask8x32(mask); + let mut merge_padded = [0u8; 32 + 1]; + merge_padded[..32].copy_from_slice(&*merge); + let mut compacted = merge_padded; + let mut output_lane = 0; + for input_lane in 0..32 { + compacted[output_lane] = values[input_lane]; + output_lane += ((mask >> input_lane) & 1) as usize; + } + compacted[output_lane] = merge_padded[output_lane]; + let mut result = merge; + result.copy_from_slice(&compacted[..32]); + result + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32; + #[inline(always)] + fn expand_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32 { + self.expand_merge_u8x32(values, mask, u8x32::splat(self, 0)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u8x32( self, values: u8x32, mask: mask8x32, merge: u8x32, - ) -> u8x32; + ) -> u8x32 { + let mask = self.to_bitmask_mask8x32(mask); + let mut result = merge; + let mut input_lane = 0; + for output_lane in 0..32 { + let bit = ((mask >> output_lane) & 1) as u8; + let keep = 0u8.wrapping_sub(bit); + result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); + input_lane += usize::from(bit); + } + result + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u8x32(self, a: u8x32) -> u8x32 { @@ -3369,14 +4316,12 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u8x32(self, a: u8x32) -> u8x32 { - let (a0, a1) = self.split_u8x32(a); - self.combine_u8x16(self.count_zeros_u8x16(a0), self.count_zeros_u8x16(a1)) + self.count_ones_u8x32(self.not_u8x32(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] fn swap_bytes_u8x32(self, a: u8x32) -> u8x32 { - let (a0, a1) = self.split_u8x32(a); - self.combine_u8x16(self.swap_bytes_u8x16(a0), self.swap_bytes_u8x16(a1)) + a } #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] #[inline(always)] @@ -3449,8 +4394,7 @@ pub trait Simd: #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u8x32(self, a: u8x32) -> u8x32 { - let (a0, a1) = self.split_u8x32(a); - self.combine_u8x16(self.not_u8x16(a0), self.not_u8x16(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -3519,10 +4463,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u8x32(self, a: u8x32, b: u8x32, c: u8x32) -> u8x32 { - let (a0, a1) = self.split_u8x32(a); - let (b0, b1) = self.split_u8x32(b); - let (c0, c1) = self.split_u8x32(c); - self.combine_u8x16(self.clamp_u8x16(a0, b0, c0), self.clamp_u8x16(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -3701,53 +4646,63 @@ pub trait Simd: lo | (hi << 16usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32; + #[inline(always)] + fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { + mask8x32 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32; + #[inline(always)] + fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { + i8x32 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask8x32( self, a: mask8x32, - ) -> mask8x32; + ) -> mask8x32 { + mask8x32::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask8x32( self, a: mask8x32, - ) -> mask8x32; + ) -> mask8x32 { + mask8x32::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { - let (a0, a1) = self.split_mask8x32(a); - let (b0, b1) = self.split_mask8x32(b); - self.combine_mask8x16(self.and_mask8x16(a0, b0), self.and_mask8x16(a1, b1)) + mask8x32::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { - let (a0, a1) = self.split_mask8x32(a); - let (b0, b1) = self.split_mask8x32(b); - self.combine_mask8x16(self.or_mask8x16(a0, b0), self.or_mask8x16(a1, b1)) + mask8x32::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { - let (a0, a1) = self.split_mask8x32(a); - let (b0, b1) = self.split_mask8x32(b); - self.combine_mask8x16(self.xor_mask8x16(a0, b0), self.xor_mask8x16(a1, b1)) + mask8x32::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask8x32(self, a: mask8x32) -> mask8x32 { - let (a0, a1) = self.split_mask8x32(a); - self.combine_mask8x16(self.not_mask8x16(a0), self.not_mask8x16(a1)) + mask8x32::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask8x32(self, a: mask8x32) -> mask8x32 { - let (a0, a1) = self.split_mask8x32(a); - self.combine_mask8x16(self.reverse_mask8x16(a1), self.reverse_mask8x16(a0)) + mask8x32::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -3898,23 +4853,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16; + #[inline(always)] + fn compress_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i16x16( self, values: i16x16, mask: mask16x16, merge: i16x16, - ) -> i16x16; + ) -> i16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16; + #[inline(always)] + fn expand_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i16x16( self, values: i16x16, mask: mask16x16, merge: i16x16, - ) -> i16x16; + ) -> i16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i16x16(self, a: i16x16) -> i16x16 { @@ -3924,8 +4903,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i16x16(self, a: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - self.combine_i16x8(self.count_zeros_i16x8(a0), self.count_zeros_i16x8(a1)) + self.count_ones_i16x16(self.not_i16x16(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -3983,29 +4961,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - let (b0, b1) = self.split_i16x16(b); - self.combine_i16x8(self.and_i16x8(a0, b0), self.and_i16x8(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - let (b0, b1) = self.split_i16x16(b); - self.combine_i16x8(self.or_i16x8(a0, b0), self.or_i16x8(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i16x16(self, a: i16x16, b: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - let (b0, b1) = self.split_i16x16(b); - self.combine_i16x8(self.xor_i16x8(a0, b0), self.xor_i16x8(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i16x16(self, a: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - self.combine_i16x8(self.not_i16x8(a0), self.not_i16x8(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -4074,10 +5045,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i16x16(self, a: i16x16, b: i16x16, c: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - let (b0, b1) = self.split_i16x16(b); - let (c0, c1) = self.split_i16x16(c); - self.combine_i16x8(self.clamp_i16x8(a0, b0, c0), self.clamp_i16x8(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -4186,8 +5158,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i16x16(self, a: i16x16) -> i16x16 { - let (a0, a1) = self.split_i16x16(a); - self.combine_i16x8(self.neg_i16x8(a0), self.neg_i16x8(a1)) + self.sub_i16x16(self.splat_i16x16(0), a) } #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] #[inline(always)] @@ -4348,23 +5319,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16; + #[inline(always)] + fn compress_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u16x16( self, values: u16x16, mask: mask16x16, merge: u16x16, - ) -> u16x16; + ) -> u16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16; + #[inline(always)] + fn expand_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u16x16( self, values: u16x16, mask: mask16x16, merge: u16x16, - ) -> u16x16; + ) -> u16x16 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u16x16(self, a: u16x16) -> u16x16 { @@ -4374,8 +5369,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u16x16(self, a: u16x16) -> u16x16 { - let (a0, a1) = self.split_u16x16(a); - self.combine_u16x8(self.count_zeros_u16x8(a0), self.count_zeros_u16x8(a1)) + self.count_ones_u16x16(self.not_u16x16(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -4433,29 +5427,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - let (a0, a1) = self.split_u16x16(a); - let (b0, b1) = self.split_u16x16(b); - self.combine_u16x8(self.and_u16x8(a0, b0), self.and_u16x8(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - let (a0, a1) = self.split_u16x16(a); - let (b0, b1) = self.split_u16x16(b); - self.combine_u16x8(self.or_u16x8(a0, b0), self.or_u16x8(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_u16x16(self, a: u16x16, b: u16x16) -> u16x16 { - let (a0, a1) = self.split_u16x16(a); - let (b0, b1) = self.split_u16x16(b); - self.combine_u16x8(self.xor_u16x8(a0, b0), self.xor_u16x8(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u16x16(self, a: u16x16) -> u16x16 { - let (a0, a1) = self.split_u16x16(a); - self.combine_u16x8(self.not_u16x8(a0), self.not_u16x8(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -4524,10 +5511,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u16x16(self, a: u16x16, b: u16x16, c: u16x16) -> u16x16 { - let (a0, a1) = self.split_u16x16(a); - let (b0, b1) = self.split_u16x16(b); - let (c0, c1) = self.split_u16x16(c); - self.combine_u16x8(self.clamp_u16x8(a0, b0, c0), self.clamp_u16x8(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -4733,53 +5721,63 @@ pub trait Simd: lo | (hi << 8usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16; + #[inline(always)] + fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { + mask16x16 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16; + #[inline(always)] + fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { + i16x16 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask16x16( self, a: mask16x16, - ) -> mask16x16; + ) -> mask16x16 { + mask16x16::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask16x16( self, a: mask16x16, - ) -> mask16x16; + ) -> mask16x16 { + mask16x16::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { - let (a0, a1) = self.split_mask16x16(a); - let (b0, b1) = self.split_mask16x16(b); - self.combine_mask16x8(self.and_mask16x8(a0, b0), self.and_mask16x8(a1, b1)) + mask16x16::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] - fn or_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { - let (a0, a1) = self.split_mask16x16(a); - let (b0, b1) = self.split_mask16x16(b); - self.combine_mask16x8(self.or_mask16x8(a0, b0), self.or_mask16x8(a1, b1)) + fn or_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { + mask16x16::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { - let (a0, a1) = self.split_mask16x16(a); - let (b0, b1) = self.split_mask16x16(b); - self.combine_mask16x8(self.xor_mask16x8(a0, b0), self.xor_mask16x8(a1, b1)) + mask16x16::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask16x16(self, a: mask16x16) -> mask16x16 { - let (a0, a1) = self.split_mask16x16(a); - self.combine_mask16x8(self.not_mask16x8(a0), self.not_mask16x8(a1)) + mask16x16::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask16x16(self, a: mask16x16) -> mask16x16 { - let (a0, a1) = self.split_mask16x16(a); - self.combine_mask16x8(self.reverse_mask16x8(a1), self.reverse_mask16x8(a0)) + mask16x16::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -4933,23 +5931,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8; + #[inline(always)] + fn compress_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i32x8( self, values: i32x8, mask: mask32x8, merge: i32x8, - ) -> i32x8; + ) -> i32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8; + #[inline(always)] + fn expand_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i32x8( self, values: i32x8, mask: mask32x8, merge: i32x8, - ) -> i32x8; + ) -> i32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i32x8(self, a: i32x8) -> i32x8 { @@ -4959,8 +5981,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i32x8(self, a: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - self.combine_i32x4(self.count_zeros_i32x4(a0), self.count_zeros_i32x4(a1)) + self.count_ones_i32x8(self.not_i32x8(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -5018,29 +6039,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - let (b0, b1) = self.split_i32x8(b); - self.combine_i32x4(self.and_i32x4(a0, b0), self.and_i32x4(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - let (b0, b1) = self.split_i32x8(b); - self.combine_i32x4(self.or_i32x4(a0, b0), self.or_i32x4(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i32x8(self, a: i32x8, b: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - let (b0, b1) = self.split_i32x8(b); - self.combine_i32x4(self.xor_i32x4(a0, b0), self.xor_i32x4(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i32x8(self, a: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - self.combine_i32x4(self.not_i32x4(a0), self.not_i32x4(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -5109,10 +6123,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i32x8(self, a: i32x8, b: i32x8, c: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - let (b0, b1) = self.split_i32x8(b); - let (c0, c1) = self.split_i32x8(c); - self.combine_i32x4(self.clamp_i32x4(a0, b0, c0), self.clamp_i32x4(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -5221,8 +6236,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i32x8(self, a: i32x8) -> i32x8 { - let (a0, a1) = self.split_i32x8(a); - self.combine_i32x4(self.neg_i32x4(a0), self.neg_i32x4(a1)) + self.sub_i32x8(self.splat_i32x8(0), a) } #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] #[inline(always)] @@ -5385,23 +6399,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8; + #[inline(always)] + fn compress_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u32x8( self, values: u32x8, mask: mask32x8, merge: u32x8, - ) -> u32x8; + ) -> u32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8; + #[inline(always)] + fn expand_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u32x8( self, values: u32x8, mask: mask32x8, merge: u32x8, - ) -> u32x8; + ) -> u32x8 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u32x8(self, a: u32x8) -> u32x8 { @@ -5411,8 +6449,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u32x8(self, a: u32x8) -> u32x8 { - let (a0, a1) = self.split_u32x8(a); - self.combine_u32x4(self.count_zeros_u32x4(a0), self.count_zeros_u32x4(a1)) + self.count_ones_u32x8(self.not_u32x8(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -5470,29 +6507,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - let (a0, a1) = self.split_u32x8(a); - let (b0, b1) = self.split_u32x8(b); - self.combine_u32x4(self.and_u32x4(a0, b0), self.and_u32x4(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - let (a0, a1) = self.split_u32x8(a); - let (b0, b1) = self.split_u32x8(b); - self.combine_u32x4(self.or_u32x4(a0, b0), self.or_u32x4(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_u32x8(self, a: u32x8, b: u32x8) -> u32x8 { - let (a0, a1) = self.split_u32x8(a); - let (b0, b1) = self.split_u32x8(b); - self.combine_u32x4(self.xor_u32x4(a0, b0), self.xor_u32x4(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u32x8(self, a: u32x8) -> u32x8 { - let (a0, a1) = self.split_u32x8(a); - self.combine_u32x4(self.not_u32x4(a0), self.not_u32x4(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -5561,10 +6591,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u32x8(self, a: u32x8, b: u32x8, c: u32x8) -> u32x8 { - let (a0, a1) = self.split_u32x8(a); - let (b0, b1) = self.split_u32x8(b); - let (c0, c1) = self.split_u32x8(c); - self.combine_u32x4(self.clamp_u32x4(a0, b0, c0), self.clamp_u32x4(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -5776,53 +6807,63 @@ pub trait Simd: lo | (hi << 4usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8; + #[inline(always)] + fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { + mask32x8 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8; + #[inline(always)] + fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { + i32x8 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask32x8( self, a: mask32x8, - ) -> mask32x8; + ) -> mask32x8 { + mask32x8::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask32x8( self, a: mask32x8, - ) -> mask32x8; + ) -> mask32x8 { + mask32x8::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { - let (a0, a1) = self.split_mask32x8(a); - let (b0, b1) = self.split_mask32x8(b); - self.combine_mask32x4(self.and_mask32x4(a0, b0), self.and_mask32x4(a1, b1)) + mask32x8::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { - let (a0, a1) = self.split_mask32x8(a); - let (b0, b1) = self.split_mask32x8(b); - self.combine_mask32x4(self.or_mask32x4(a0, b0), self.or_mask32x4(a1, b1)) + mask32x8::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { - let (a0, a1) = self.split_mask32x8(a); - let (b0, b1) = self.split_mask32x8(b); - self.combine_mask32x4(self.xor_mask32x4(a0, b0), self.xor_mask32x4(a1, b1)) + mask32x8::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask32x8(self, a: mask32x8) -> mask32x8 { - let (a0, a1) = self.split_mask32x8(a); - self.combine_mask32x4(self.not_mask32x4(a0), self.not_mask32x4(a1)) + mask32x8::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask32x8(self, a: mask32x8) -> mask32x8 { - let (a0, a1) = self.split_mask32x8(a); - self.combine_mask32x4(self.reverse_mask32x4(a1), self.reverse_mask32x4(a0)) + mask32x8::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -5976,23 +7017,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4; + #[inline(always)] + fn compress_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_f64x4( self, values: f64x4, mask: mask64x4, merge: f64x4, - ) -> f64x4; + ) -> f64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4; + #[inline(always)] + fn expand_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_f64x4( self, values: f64x4, mask: mask64x4, merge: f64x4, - ) -> f64x4; + ) -> f64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Negate each element of the vector."] #[inline(always)] fn neg_f64x4(self, a: f64x4) -> f64x4 { @@ -6315,19 +7380,44 @@ pub trait Simd: self.combine_f64x2(self.to_radians_f64x2(a0), self.to_radians_f64x2(a1)) } #[doc = "Return a mask indicating which elements are NaN."] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { + a.simd_ne(a) + } #[doc = "Return a mask indicating which elements are positive or negative infinite."] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { + a.abs().simd_eq(f64::INFINITY) + } #[doc = "Return a mask indicating which elements are neither infinite nor NaN."] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { + a.abs().simd_lt(f64::INFINITY) + } #[doc = "Return a mask indicating which elements are subnormal.\n\nThis classifies the stored bit pattern, even when floating-point operations treat subnormals as zero."] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { + let i: i64x4 = a.bitcast(); + (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) + } #[doc = "Return a mask indicating which elements are neither zero, infinite, subnormal, or NaN."] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { + let i: i64x4 = a.bitcast(); + let exp = i & 0x7FF0_0000_0000_0000_i64; + exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) + } #[doc = "Return a mask indicating which elements have a positive sign, including `+0.0`, NaNs with positive sign bit and positive infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_positive`] for details."] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { + let i: i64x4 = a.bitcast(); + (i & i64::MIN).simd_eq(0) + } #[doc = "Return a mask indicating which elements have a negative sign, including `-0.0`, NaNs with negative sign bit and negative infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_negative`] for details."] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4; + #[inline(always)] + fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { + !a.is_sign_positive() + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] fn select_f64x4(self, a: mask64x4, b: f64x4, c: f64x4) -> f64x4 { @@ -6475,23 +7565,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4; + #[inline(always)] + fn compress_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i64x4( self, values: i64x4, mask: mask64x4, merge: i64x4, - ) -> i64x4; + ) -> i64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4; + #[inline(always)] + fn expand_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i64x4( self, values: i64x4, mask: mask64x4, merge: i64x4, - ) -> i64x4; + ) -> i64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i64x4(self, a: i64x4) -> i64x4 { @@ -6501,8 +7615,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i64x4(self, a: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - self.combine_i64x2(self.count_zeros_i64x2(a0), self.count_zeros_i64x2(a1)) + self.count_ones_i64x4(self.not_i64x4(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -6560,29 +7673,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - let (b0, b1) = self.split_i64x4(b); - self.combine_i64x2(self.and_i64x2(a0, b0), self.and_i64x2(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - let (b0, b1) = self.split_i64x4(b); - self.combine_i64x2(self.or_i64x2(a0, b0), self.or_i64x2(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i64x4(self, a: i64x4, b: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - let (b0, b1) = self.split_i64x4(b); - self.combine_i64x2(self.xor_i64x2(a0, b0), self.xor_i64x2(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i64x4(self, a: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - self.combine_i64x2(self.not_i64x2(a0), self.not_i64x2(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -6651,10 +7757,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i64x4(self, a: i64x4, b: i64x4, c: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - let (b0, b1) = self.split_i64x4(b); - let (c0, c1) = self.split_i64x4(c); - self.combine_i64x2(self.clamp_i64x2(a0, b0, c0), self.clamp_i64x2(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -6763,8 +7870,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i64x4(self, a: i64x4) -> i64x4 { - let (a0, a1) = self.split_i64x4(a); - self.combine_i64x2(self.neg_i64x2(a0), self.neg_i64x2(a1)) + self.sub_i64x4(self.splat_i64x4(0), a) } #[doc = "Truncate the lanes of two vectors and concatenate them into one same-width vector.\n\nEach lane retains its low destination-width bits. `a` provides the lower result lanes and `b` provides the upper result lanes."] #[inline(always)] @@ -6876,23 +7982,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4; + #[inline(always)] + fn compress_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u64x4( self, values: u64x4, mask: mask64x4, merge: u64x4, - ) -> u64x4; + ) -> u64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4; + #[inline(always)] + fn expand_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u64x4( self, values: u64x4, mask: mask64x4, merge: u64x4, - ) -> u64x4; + ) -> u64x4 { + let mask = mask8x32::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x32( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u64x4(self, a: u64x4) -> u64x4 { @@ -6902,8 +8032,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u64x4(self, a: u64x4) -> u64x4 { - let (a0, a1) = self.split_u64x4(a); - self.combine_u64x2(self.count_zeros_u64x2(a0), self.count_zeros_u64x2(a1)) + self.count_ones_u64x4(self.not_u64x4(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -6961,29 +8090,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - let (a0, a1) = self.split_u64x4(a); - let (b0, b1) = self.split_u64x4(b); - self.combine_u64x2(self.and_u64x2(a0, b0), self.and_u64x2(a1, b1)) + Bytes::from_bytes(self.and_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - let (a0, a1) = self.split_u64x4(a); - let (b0, b1) = self.split_u64x4(b); - self.combine_u64x2(self.or_u64x2(a0, b0), self.or_u64x2(a1, b1)) + Bytes::from_bytes(self.or_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_u64x4(self, a: u64x4, b: u64x4) -> u64x4 { - let (a0, a1) = self.split_u64x4(a); - let (b0, b1) = self.split_u64x4(b); - self.combine_u64x2(self.xor_u64x2(a0, b0), self.xor_u64x2(a1, b1)) + Bytes::from_bytes(self.xor_u8x32(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u64x4(self, a: u64x4) -> u64x4 { - let (a0, a1) = self.split_u64x4(a); - self.combine_u64x2(self.not_u64x2(a0), self.not_u64x2(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -7052,10 +8174,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u64x4(self, a: u64x4, b: u64x4, c: u64x4) -> u64x4 { - let (a0, a1) = self.split_u64x4(a); - let (b0, b1) = self.split_u64x4(b); - let (c0, c1) = self.split_u64x4(c); - self.combine_u64x2(self.clamp_u64x2(a0, b0, c0), self.clamp_u64x2(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -7216,53 +8339,63 @@ pub trait Simd: lo | (hi << 2usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4; + #[inline(always)] + fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { + mask64x4 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4; + #[inline(always)] + fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { + i64x4 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask64x4( self, a: mask64x4, - ) -> mask64x4; + ) -> mask64x4 { + mask64x4::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask64x4( self, a: mask64x4, - ) -> mask64x4; + ) -> mask64x4 { + mask64x4::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { - let (a0, a1) = self.split_mask64x4(a); - let (b0, b1) = self.split_mask64x4(b); - self.combine_mask64x2(self.and_mask64x2(a0, b0), self.and_mask64x2(a1, b1)) + mask64x4::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { - let (a0, a1) = self.split_mask64x4(a); - let (b0, b1) = self.split_mask64x4(b); - self.combine_mask64x2(self.or_mask64x2(a0, b0), self.or_mask64x2(a1, b1)) + mask64x4::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { - let (a0, a1) = self.split_mask64x4(a); - let (b0, b1) = self.split_mask64x4(b); - self.combine_mask64x2(self.xor_mask64x2(a0, b0), self.xor_mask64x2(a1, b1)) + mask64x4::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask64x4(self, a: mask64x4) -> mask64x4 { - let (a0, a1) = self.split_mask64x4(a); - self.combine_mask64x2(self.not_mask64x2(a0), self.not_mask64x2(a1)) + mask64x4::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask64x4(self, a: mask64x4) -> mask64x4 { - let (a0, a1) = self.split_mask64x4(a); - self.combine_mask64x2(self.reverse_mask64x2(a1), self.reverse_mask64x2(a0)) + mask64x4::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -7409,23 +8542,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16; + #[inline(always)] + fn compress_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_f32x16( self, values: f32x16, mask: mask32x16, merge: f32x16, - ) -> f32x16; + ) -> f32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16; + #[inline(always)] + fn expand_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_f32x16( self, values: f32x16, mask: mask32x16, merge: f32x16, - ) -> f32x16; + ) -> f32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Negate each element of the vector."] #[inline(always)] fn neg_f32x16(self, a: f32x16) -> f32x16 { @@ -7758,19 +8915,44 @@ pub trait Simd: self.combine_f32x8(self.to_radians_f32x8(a0), self.to_radians_f32x8(a1)) } #[doc = "Return a mask indicating which elements are NaN."] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { + a.simd_ne(a) + } #[doc = "Return a mask indicating which elements are positive or negative infinite."] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { + a.abs().simd_eq(f32::INFINITY) + } #[doc = "Return a mask indicating which elements are neither infinite nor NaN."] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { + a.abs().simd_lt(f32::INFINITY) + } #[doc = "Return a mask indicating which elements are subnormal.\n\nThis classifies the stored bit pattern, even when floating-point operations treat subnormals as zero."] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { + let i: i32x16 = a.bitcast(); + (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) + } #[doc = "Return a mask indicating which elements are neither zero, infinite, subnormal, or NaN."] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { + let i: i32x16 = a.bitcast(); + let exp = i & 0x7F80_0000_i32; + exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) + } #[doc = "Return a mask indicating which elements have a positive sign, including `+0.0`, NaNs with positive sign bit and positive infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_positive`] for details."] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { + let i: i32x16 = a.bitcast(); + (i & i32::MIN).simd_eq(0) + } #[doc = "Return a mask indicating which elements have a negative sign, including `-0.0`, NaNs with negative sign bit and negative infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_negative`] for details."] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16; + #[inline(always)] + fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { + !a.is_sign_positive() + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] fn select_f32x16(self, a: mask32x16, b: f32x16, c: f32x16) -> f32x16 { @@ -7897,23 +9079,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64; + #[inline(always)] + fn compress_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i8x64( self, values: i8x64, mask: mask8x64, merge: i8x64, - ) -> i8x64; + ) -> i8x64 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64; + #[inline(always)] + fn expand_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i8x64( self, values: i8x64, mask: mask8x64, merge: i8x64, - ) -> i8x64; + ) -> i8x64 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i8x64(self, a: i8x64) -> i8x64 { @@ -7923,14 +9129,12 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i8x64(self, a: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - self.combine_i8x32(self.count_zeros_i8x32(a0), self.count_zeros_i8x32(a1)) + self.count_ones_i8x64(self.not_i8x64(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] fn swap_bytes_i8x64(self, a: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - self.combine_i8x32(self.swap_bytes_i8x32(a0), self.swap_bytes_i8x32(a1)) + a } #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] #[inline(always)] @@ -7982,29 +9186,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i8x64(self, a: i8x64, b: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - let (b0, b1) = self.split_i8x64(b); - self.combine_i8x32(self.and_i8x32(a0, b0), self.and_i8x32(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i8x64(self, a: i8x64, b: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - let (b0, b1) = self.split_i8x64(b); - self.combine_i8x32(self.or_i8x32(a0, b0), self.or_i8x32(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i8x64(self, a: i8x64, b: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - let (b0, b1) = self.split_i8x64(b); - self.combine_i8x32(self.xor_i8x32(a0, b0), self.xor_i8x32(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i8x64(self, a: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - self.combine_i8x32(self.not_i8x32(a0), self.not_i8x32(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -8073,10 +9270,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i8x64(self, a: i8x64, b: i8x64, c: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - let (b0, b1) = self.split_i8x64(b); - let (c0, c1) = self.split_i8x64(c); - self.combine_i8x32(self.clamp_i8x32(a0, b0, c0), self.clamp_i8x32(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -8183,8 +9381,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i8x64(self, a: i8x64) -> i8x64 { - let (a0, a1) = self.split_i8x64(a); - self.combine_i8x32(self.neg_i8x32(a0), self.neg_i8x32(a1)) + self.sub_i8x64(self.splat_i8x64(0), a) } #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] #[inline(always)] @@ -8299,23 +9496,56 @@ pub trait Simd: indices: u8x64, ) -> u8x64; #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64; + #[inline(always)] + fn compress_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64 { + self.compress_merge_u8x64(values, mask, u8x64::splat(self, 0)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u8x64( self, values: u8x64, mask: mask8x64, merge: u8x64, - ) -> u8x64; + ) -> u8x64 { + let mask = self.to_bitmask_mask8x64(mask); + let mut merge_padded = [0u8; 64 + 1]; + merge_padded[..64].copy_from_slice(&*merge); + let mut compacted = merge_padded; + let mut output_lane = 0; + for input_lane in 0..64 { + compacted[output_lane] = values[input_lane]; + output_lane += ((mask >> input_lane) & 1) as usize; + } + compacted[output_lane] = merge_padded[output_lane]; + let mut result = merge; + result.copy_from_slice(&compacted[..64]); + result + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64; + #[inline(always)] + fn expand_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64 { + self.expand_merge_u8x64(values, mask, u8x64::splat(self, 0)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u8x64( self, values: u8x64, mask: mask8x64, merge: u8x64, - ) -> u8x64; + ) -> u8x64 { + let mask = self.to_bitmask_mask8x64(mask); + let mut result = merge; + let mut input_lane = 0; + for output_lane in 0..64 { + let bit = ((mask >> output_lane) & 1) as u8; + let keep = 0u8.wrapping_sub(bit); + result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); + input_lane += usize::from(bit); + } + result + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u8x64(self, a: u8x64) -> u8x64 { @@ -8325,14 +9555,12 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u8x64(self, a: u8x64) -> u8x64 { - let (a0, a1) = self.split_u8x64(a); - self.combine_u8x32(self.count_zeros_u8x32(a0), self.count_zeros_u8x32(a1)) + self.count_ones_u8x64(self.not_u8x64(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] fn swap_bytes_u8x64(self, a: u8x64) -> u8x64 { - let (a0, a1) = self.split_u8x64(a); - self.combine_u8x32(self.swap_bytes_u8x32(a0), self.swap_bytes_u8x32(a1)) + a } #[doc = "Reverses the order bits in an integer. I.e. the least significant bit becomes the most significant bit and vice versa.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet i = u32x4::from_slice(simd, &[0x01_23_45_67, 0x89_AB_CD_EF, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*i.reverse_bits(), [0xE6_A2_C4_80, 0xF7_B3_D5_91, 0xD0_50_90_10, 0xF0_70_B0_30]);\n# });\n```"] #[inline(always)] @@ -8405,8 +9633,7 @@ pub trait Simd: #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u8x64(self, a: u8x64) -> u8x64 { - let (a0, a1) = self.split_u8x64(a); - self.combine_u8x32(self.not_u8x32(a0), self.not_u8x32(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -8475,10 +9702,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u8x64(self, a: u8x64, b: u8x64, c: u8x64) -> u8x64 { - let (a0, a1) = self.split_u8x64(a); - let (b0, b1) = self.split_u8x64(b); - let (c0, c1) = self.split_u8x64(c); - self.combine_u8x32(self.clamp_u8x32(a0, b0, c0), self.clamp_u8x32(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -8655,53 +9883,63 @@ pub trait Simd: lo | (hi << 32usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64; + #[inline(always)] + fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { + mask8x64 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64; + #[inline(always)] + fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { + i8x64 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask8x64( self, a: mask8x64, - ) -> mask8x64; + ) -> mask8x64 { + mask8x64::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask8x64( self, a: mask8x64, - ) -> mask8x64; + ) -> mask8x64 { + mask8x64::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask8x64(self, a: mask8x64, b: mask8x64) -> mask8x64 { - let (a0, a1) = self.split_mask8x64(a); - let (b0, b1) = self.split_mask8x64(b); - self.combine_mask8x32(self.and_mask8x32(a0, b0), self.and_mask8x32(a1, b1)) + mask8x64::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask8x64(self, a: mask8x64, b: mask8x64) -> mask8x64 { - let (a0, a1) = self.split_mask8x64(a); - let (b0, b1) = self.split_mask8x64(b); - self.combine_mask8x32(self.or_mask8x32(a0, b0), self.or_mask8x32(a1, b1)) + mask8x64::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask8x64(self, a: mask8x64, b: mask8x64) -> mask8x64 { - let (a0, a1) = self.split_mask8x64(a); - let (b0, b1) = self.split_mask8x64(b); - self.combine_mask8x32(self.xor_mask8x32(a0, b0), self.xor_mask8x32(a1, b1)) + mask8x64::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask8x64(self, a: mask8x64) -> mask8x64 { - let (a0, a1) = self.split_mask8x64(a); - self.combine_mask8x32(self.not_mask8x32(a0), self.not_mask8x32(a1)) + mask8x64::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask8x64(self, a: mask8x64) -> mask8x64 { - let (a0, a1) = self.split_mask8x64(a); - self.combine_mask8x32(self.reverse_mask8x32(a1), self.reverse_mask8x32(a0)) + mask8x64::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -8850,23 +10088,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32; + #[inline(always)] + fn compress_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i16x32( self, values: i16x32, mask: mask16x32, merge: i16x32, - ) -> i16x32; + ) -> i16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32; + #[inline(always)] + fn expand_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i16x32( self, values: i16x32, mask: mask16x32, merge: i16x32, - ) -> i16x32; + ) -> i16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i16x32(self, a: i16x32) -> i16x32 { @@ -8876,8 +10138,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i16x32(self, a: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - self.combine_i16x16(self.count_zeros_i16x16(a0), self.count_zeros_i16x16(a1)) + self.count_ones_i16x32(self.not_i16x32(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -8935,29 +10196,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i16x32(self, a: i16x32, b: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - let (b0, b1) = self.split_i16x32(b); - self.combine_i16x16(self.and_i16x16(a0, b0), self.and_i16x16(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i16x32(self, a: i16x32, b: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - let (b0, b1) = self.split_i16x32(b); - self.combine_i16x16(self.or_i16x16(a0, b0), self.or_i16x16(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i16x32(self, a: i16x32, b: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - let (b0, b1) = self.split_i16x32(b); - self.combine_i16x16(self.xor_i16x16(a0, b0), self.xor_i16x16(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i16x32(self, a: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - self.combine_i16x16(self.not_i16x16(a0), self.not_i16x16(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -9026,10 +10280,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i16x32(self, a: i16x32, b: i16x32, c: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - let (b0, b1) = self.split_i16x32(b); - let (c0, c1) = self.split_i16x32(c); - self.combine_i16x16(self.clamp_i16x16(a0, b0, c0), self.clamp_i16x16(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -9142,8 +10397,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i16x32(self, a: i16x32) -> i16x32 { - let (a0, a1) = self.split_i16x32(a); - self.combine_i16x16(self.neg_i16x16(a0), self.neg_i16x16(a1)) + self.sub_i16x32(self.splat_i16x32(0), a) } #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] #[inline(always)] @@ -9304,23 +10558,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32; + #[inline(always)] + fn compress_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u16x32( self, values: u16x32, mask: mask16x32, merge: u16x32, - ) -> u16x32; + ) -> u16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32; + #[inline(always)] + fn expand_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u16x32( self, values: u16x32, mask: mask16x32, merge: u16x32, - ) -> u16x32; + ) -> u16x32 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u16x32(self, a: u16x32) -> u16x32 { @@ -9330,8 +10608,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u16x32(self, a: u16x32) -> u16x32 { - let (a0, a1) = self.split_u16x32(a); - self.combine_u16x16(self.count_zeros_u16x16(a0), self.count_zeros_u16x16(a1)) + self.count_ones_u16x32(self.not_u16x32(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -9389,29 +10666,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_u16x32(self, a: u16x32, b: u16x32) -> u16x32 { - let (a0, a1) = self.split_u16x32(a); - let (b0, b1) = self.split_u16x32(b); - self.combine_u16x16(self.and_u16x16(a0, b0), self.and_u16x16(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_u16x32(self, a: u16x32, b: u16x32) -> u16x32 { - let (a0, a1) = self.split_u16x32(a); - let (b0, b1) = self.split_u16x32(b); - self.combine_u16x16(self.or_u16x16(a0, b0), self.or_u16x16(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_u16x32(self, a: u16x32, b: u16x32) -> u16x32 { - let (a0, a1) = self.split_u16x32(a); - let (b0, b1) = self.split_u16x32(b); - self.combine_u16x16(self.xor_u16x16(a0, b0), self.xor_u16x16(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u16x32(self, a: u16x32) -> u16x32 { - let (a0, a1) = self.split_u16x32(a); - self.combine_u16x16(self.not_u16x16(a0), self.not_u16x16(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -9480,10 +10750,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u16x32(self, a: u16x32, b: u16x32, c: u16x32) -> u16x32 { - let (a0, a1) = self.split_u16x32(a); - let (b0, b1) = self.split_u16x32(b); - let (c0, c1) = self.split_u16x32(c); - self.combine_u16x16(self.clamp_u16x16(a0, b0, c0), self.clamp_u16x16(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -9693,53 +10964,63 @@ pub trait Simd: lo | (hi << 16usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32; + #[inline(always)] + fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { + mask16x32 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32; + #[inline(always)] + fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { + i16x32 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask16x32( self, a: mask16x32, - ) -> mask16x32; + ) -> mask16x32 { + mask16x32::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask16x32( self, a: mask16x32, - ) -> mask16x32; + ) -> mask16x32 { + mask16x32::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask16x32(self, a: mask16x32, b: mask16x32) -> mask16x32 { - let (a0, a1) = self.split_mask16x32(a); - let (b0, b1) = self.split_mask16x32(b); - self.combine_mask16x16(self.and_mask16x16(a0, b0), self.and_mask16x16(a1, b1)) + mask16x32::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask16x32(self, a: mask16x32, b: mask16x32) -> mask16x32 { - let (a0, a1) = self.split_mask16x32(a); - let (b0, b1) = self.split_mask16x32(b); - self.combine_mask16x16(self.or_mask16x16(a0, b0), self.or_mask16x16(a1, b1)) + mask16x32::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask16x32(self, a: mask16x32, b: mask16x32) -> mask16x32 { - let (a0, a1) = self.split_mask16x32(a); - let (b0, b1) = self.split_mask16x32(b); - self.combine_mask16x16(self.xor_mask16x16(a0, b0), self.xor_mask16x16(a1, b1)) + mask16x32::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask16x32(self, a: mask16x32) -> mask16x32 { - let (a0, a1) = self.split_mask16x32(a); - self.combine_mask16x16(self.not_mask16x16(a0), self.not_mask16x16(a1)) + mask16x32::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask16x32(self, a: mask16x32) -> mask16x32 { - let (a0, a1) = self.split_mask16x32(a); - self.combine_mask16x16(self.reverse_mask16x16(a1), self.reverse_mask16x16(a0)) + mask16x32::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -9898,23 +11179,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16; + #[inline(always)] + fn compress_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i32x16( self, values: i32x16, mask: mask32x16, merge: i32x16, - ) -> i32x16; + ) -> i32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16; + #[inline(always)] + fn expand_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i32x16( self, values: i32x16, mask: mask32x16, merge: i32x16, - ) -> i32x16; + ) -> i32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i32x16(self, a: i32x16) -> i32x16 { @@ -9924,8 +11229,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i32x16(self, a: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - self.combine_i32x8(self.count_zeros_i32x8(a0), self.count_zeros_i32x8(a1)) + self.count_ones_i32x16(self.not_i32x16(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -9983,29 +11287,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i32x16(self, a: i32x16, b: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - let (b0, b1) = self.split_i32x16(b); - self.combine_i32x8(self.and_i32x8(a0, b0), self.and_i32x8(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i32x16(self, a: i32x16, b: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - let (b0, b1) = self.split_i32x16(b); - self.combine_i32x8(self.or_i32x8(a0, b0), self.or_i32x8(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i32x16(self, a: i32x16, b: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - let (b0, b1) = self.split_i32x16(b); - self.combine_i32x8(self.xor_i32x8(a0, b0), self.xor_i32x8(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i32x16(self, a: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - self.combine_i32x8(self.not_i32x8(a0), self.not_i32x8(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -10074,10 +11371,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i32x16(self, a: i32x16, b: i32x16, c: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - let (b0, b1) = self.split_i32x16(b); - let (c0, c1) = self.split_i32x16(c); - self.combine_i32x8(self.clamp_i32x8(a0, b0, c0), self.clamp_i32x8(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -10184,8 +11482,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i32x16(self, a: i32x16) -> i32x16 { - let (a0, a1) = self.split_i32x16(a); - self.combine_i32x8(self.neg_i32x8(a0), self.neg_i32x8(a1)) + self.sub_i32x16(self.splat_i32x16(0), a) } #[doc = "Widen every lane into two same-width vectors.\n\nThe first result contains the widened lower lanes and the second contains the widened upper lanes."] #[inline(always)] @@ -10352,23 +11649,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16; + #[inline(always)] + fn compress_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u32x16( self, values: u32x16, mask: mask32x16, merge: u32x16, - ) -> u32x16; + ) -> u32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16; + #[inline(always)] + fn expand_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u32x16( self, values: u32x16, mask: mask32x16, merge: u32x16, - ) -> u32x16; + ) -> u32x16 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u32x16(self, a: u32x16) -> u32x16 { @@ -10378,8 +11699,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u32x16(self, a: u32x16) -> u32x16 { - let (a0, a1) = self.split_u32x16(a); - self.combine_u32x8(self.count_zeros_u32x8(a0), self.count_zeros_u32x8(a1)) + self.count_ones_u32x16(self.not_u32x16(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -10437,29 +11757,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_u32x16(self, a: u32x16, b: u32x16) -> u32x16 { - let (a0, a1) = self.split_u32x16(a); - let (b0, b1) = self.split_u32x16(b); - self.combine_u32x8(self.and_u32x8(a0, b0), self.and_u32x8(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_u32x16(self, a: u32x16, b: u32x16) -> u32x16 { - let (a0, a1) = self.split_u32x16(a); - let (b0, b1) = self.split_u32x16(b); - self.combine_u32x8(self.or_u32x8(a0, b0), self.or_u32x8(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_u32x16(self, a: u32x16, b: u32x16) -> u32x16 { - let (a0, a1) = self.split_u32x16(a); - let (b0, b1) = self.split_u32x16(b); - self.combine_u32x8(self.xor_u32x8(a0, b0), self.xor_u32x8(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u32x16(self, a: u32x16) -> u32x16 { - let (a0, a1) = self.split_u32x16(a); - self.combine_u32x8(self.not_u32x8(a0), self.not_u32x8(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -10528,10 +11841,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u32x16(self, a: u32x16, b: u32x16, c: u32x16) -> u32x16 { - let (a0, a1) = self.split_u32x16(a); - let (b0, b1) = self.split_u32x16(b); - let (c0, c1) = self.split_u32x16(c); - self.combine_u32x8(self.clamp_u32x8(a0, b0, c0), self.clamp_u32x8(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -10741,53 +12055,63 @@ pub trait Simd: lo | (hi << 8usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16; + #[inline(always)] + fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { + mask32x16 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16; + #[inline(always)] + fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { + i32x16 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask32x16( self, a: mask32x16, - ) -> mask32x16; + ) -> mask32x16 { + mask32x16::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask32x16( self, a: mask32x16, - ) -> mask32x16; + ) -> mask32x16 { + mask32x16::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask32x16(self, a: mask32x16, b: mask32x16) -> mask32x16 { - let (a0, a1) = self.split_mask32x16(a); - let (b0, b1) = self.split_mask32x16(b); - self.combine_mask32x8(self.and_mask32x8(a0, b0), self.and_mask32x8(a1, b1)) + mask32x16::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask32x16(self, a: mask32x16, b: mask32x16) -> mask32x16 { - let (a0, a1) = self.split_mask32x16(a); - let (b0, b1) = self.split_mask32x16(b); - self.combine_mask32x8(self.or_mask32x8(a0, b0), self.or_mask32x8(a1, b1)) + mask32x16::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask32x16(self, a: mask32x16, b: mask32x16) -> mask32x16 { - let (a0, a1) = self.split_mask32x16(a); - let (b0, b1) = self.split_mask32x16(b); - self.combine_mask32x8(self.xor_mask32x8(a0, b0), self.xor_mask32x8(a1, b1)) + mask32x16::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask32x16(self, a: mask32x16) -> mask32x16 { - let (a0, a1) = self.split_mask32x16(a); - self.combine_mask32x8(self.not_mask32x8(a0), self.not_mask32x8(a1)) + mask32x16::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask32x16(self, a: mask32x16) -> mask32x16 { - let (a0, a1) = self.split_mask32x16(a); - self.combine_mask32x8(self.reverse_mask32x8(a1), self.reverse_mask32x8(a0)) + mask32x16::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -10939,23 +12263,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8; + #[inline(always)] + fn compress_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_f64x8( self, values: f64x8, mask: mask64x8, merge: f64x8, - ) -> f64x8; + ) -> f64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8; + #[inline(always)] + fn expand_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_f64x8( self, values: f64x8, mask: mask64x8, merge: f64x8, - ) -> f64x8; + ) -> f64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Negate each element of the vector."] #[inline(always)] fn neg_f64x8(self, a: f64x8) -> f64x8 { @@ -11278,19 +12626,44 @@ pub trait Simd: self.combine_f64x4(self.to_radians_f64x4(a0), self.to_radians_f64x4(a1)) } #[doc = "Return a mask indicating which elements are NaN."] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { + a.simd_ne(a) + } #[doc = "Return a mask indicating which elements are positive or negative infinite."] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { + a.abs().simd_eq(f64::INFINITY) + } #[doc = "Return a mask indicating which elements are neither infinite nor NaN."] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { + a.abs().simd_lt(f64::INFINITY) + } #[doc = "Return a mask indicating which elements are subnormal.\n\nThis classifies the stored bit pattern, even when floating-point operations treat subnormals as zero."] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { + let i: i64x8 = a.bitcast(); + (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) + } #[doc = "Return a mask indicating which elements are neither zero, infinite, subnormal, or NaN."] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { + let i: i64x8 = a.bitcast(); + let exp = i & 0x7FF0_0000_0000_0000_i64; + exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) + } #[doc = "Return a mask indicating which elements have a positive sign, including `+0.0`, NaNs with positive sign bit and positive infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_positive`] for details."] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { + let i: i64x8 = a.bitcast(); + (i & i64::MIN).simd_eq(0) + } #[doc = "Return a mask indicating which elements have a negative sign, including `-0.0`, NaNs with negative sign bit and negative infinity.\n\nNaN inputs may produce an unexpected or non-portable result, see [`f32::is_sign_negative`] for details."] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8; + #[inline(always)] + fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { + !a.is_sign_positive() + } #[doc = "Select elements from b and c based on the mask operand a.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] fn select_f64x8(self, a: mask64x8, b: f64x8, c: f64x8) -> f64x8 { @@ -11436,23 +12809,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8; + #[inline(always)] + fn compress_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_i64x8( self, values: i64x8, mask: mask64x8, merge: i64x8, - ) -> i64x8; + ) -> i64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8; + #[inline(always)] + fn expand_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_i64x8( self, values: i64x8, mask: mask64x8, merge: i64x8, - ) -> i64x8; + ) -> i64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_i64x8(self, a: i64x8) -> i64x8 { @@ -11462,8 +12859,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_i64x8(self, a: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - self.combine_i64x4(self.count_zeros_i64x4(a0), self.count_zeros_i64x4(a1)) + self.count_ones_i64x8(self.not_i64x8(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -11521,29 +12917,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_i64x8(self, a: i64x8, b: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - let (b0, b1) = self.split_i64x8(b); - self.combine_i64x4(self.and_i64x4(a0, b0), self.and_i64x4(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_i64x8(self, a: i64x8, b: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - let (b0, b1) = self.split_i64x8(b); - self.combine_i64x4(self.or_i64x4(a0, b0), self.or_i64x4(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_i64x8(self, a: i64x8, b: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - let (b0, b1) = self.split_i64x8(b); - self.combine_i64x4(self.xor_i64x4(a0, b0), self.xor_i64x4(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_i64x8(self, a: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - self.combine_i64x4(self.not_i64x4(a0), self.not_i64x4(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -11612,10 +13001,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_i64x8(self, a: i64x8, b: i64x8, c: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - let (b0, b1) = self.split_i64x8(b); - let (c0, c1) = self.split_i64x8(c); - self.combine_i64x4(self.clamp_i64x4(a0, b0, c0), self.clamp_i64x4(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -11722,8 +13112,7 @@ pub trait Simd: #[doc = "Negate each element of the vector, wrapping on overflow."] #[inline(always)] fn neg_i64x8(self, a: i64x8) -> i64x8 { - let (a0, a1) = self.split_i64x8(a); - self.combine_i64x4(self.neg_i64x4(a0), self.neg_i64x4(a1)) + self.sub_i64x8(self.splat_i64x8(0), a) } #[doc = "Truncate the lanes of two vectors and concatenate them into one same-width vector.\n\nEach lane retains its low destination-width bits. `a` provides the lower result lanes and `b` provides the upper result lanes."] #[inline(always)] @@ -11835,23 +13224,47 @@ pub trait Simd: )) } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\nThis is equivalent to [`SimdBase::compress_merge`] with a zeroed merge vector."] - fn compress_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8; + #[inline(always)] + fn compress_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Compact the elements selected by `mask` into consecutive low lanes, preserving their order.\n\nLanes above the number of selected elements retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[k] = values[i];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn compress_merge_u64x8( self, values: u64x8, mask: mask64x8, merge: u64x8, - ) -> u64x8; + ) -> u64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.compress_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes are zero (positive zero for floats).\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros..\n\nThis is equivalent to [`SimdBase::expand_merge`] with a zeroed merge vector."] - fn expand_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8; + #[inline(always)] + fn expand_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) + } #[doc = "Expand consecutive low elements from `values` into the lanes selected by `mask`, preserving their order.\n\nUnselected lanes retain the corresponding values from `merge`.\n\nElements are moved without changing their bits, including floating-point NaN payloads and signed zeros.\n\n## Pseudo code\n\n```ignore\nlet mut result = merge;\nlet mut k = 0;\nfor i in 0..LEN {\n if mask[i] {\n result[i] = values[k];\n k += 1;\n }\n}\nreturn result;\n```"] + #[inline(always)] fn expand_merge_u64x8( self, values: u64x8, mask: mask64x8, merge: u64x8, - ) -> u64x8; + ) -> u64x8 { + let mask = mask8x64::from_vector(mask.to_vector().bitcast::>()); + Bytes::from_bytes(self.expand_merge_u8x64( + Bytes::to_bytes(values), + mask, + Bytes::to_bytes(merge), + )) + } #[doc = "Return the number of ones in the binary representation of each element."] #[inline(always)] fn count_ones_u64x8(self, a: u64x8) -> u64x8 { @@ -11861,8 +13274,7 @@ pub trait Simd: #[doc = "Return the number of zeros in the binary representation of each element."] #[inline(always)] fn count_zeros_u64x8(self, a: u64x8) -> u64x8 { - let (a0, a1) = self.split_u64x8(a); - self.combine_u64x4(self.count_zeros_u64x4(a0), self.count_zeros_u64x4(a1)) + self.count_ones_u64x8(self.not_u64x8(a)) } #[doc = "Reverses the byte order of the integer.\n\n# Examples\n\n```\n# use fearless_simd::*;\n# dispatch!(Level::new(), simd => {\nlet a = u16x8::from_slice(simd, &[0x00_01, 0x02_03, 0x04_05, 0x06_07, 0x08_09, 0x0A_0B, 0x0C_0D, 0x0E_0F]);\nassert_eq!(*a.swap_bytes(), [0x01_00, 0x03_02, 0x05_04, 0x07_06, 0x09_08, 0x0B_0A, 0x0D_0C, 0x0F_0E]);\n\nlet b = u32x4::from_slice(simd, &[0x00_01_02_03, 0x04_05_06_07, 0x08_09_0A_0B, 0x0C_0D_0E_0F]);\nassert_eq!(*b.swap_bytes(), [0x03_02_01_00, 0x07_06_05_04, 0x0B_0A_09_08, 0x0F_0E_0D_0C]);\n\nlet c = u64x2::from_slice(simd, &[0x00_01_02_03_04_05_06_07, 0x08_09_0A_0B_0C_0D_0E_0F]);\nassert_eq!(*c.swap_bytes(), [0x07_06_05_04_03_02_01_00, 0x0F_0E_0D_0C_0B_0A_09_08]);\n# });\n```"] #[inline(always)] @@ -11920,29 +13332,22 @@ pub trait Simd: #[doc = "Compute the bitwise AND of two vectors."] #[inline(always)] fn and_u64x8(self, a: u64x8, b: u64x8) -> u64x8 { - let (a0, a1) = self.split_u64x8(a); - let (b0, b1) = self.split_u64x8(b); - self.combine_u64x4(self.and_u64x4(a0, b0), self.and_u64x4(a1, b1)) + Bytes::from_bytes(self.and_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise OR of two vectors."] #[inline(always)] fn or_u64x8(self, a: u64x8, b: u64x8) -> u64x8 { - let (a0, a1) = self.split_u64x8(a); - let (b0, b1) = self.split_u64x8(b); - self.combine_u64x4(self.or_u64x4(a0, b0), self.or_u64x4(a1, b1)) + Bytes::from_bytes(self.or_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise XOR of two vectors."] #[inline(always)] fn xor_u64x8(self, a: u64x8, b: u64x8) -> u64x8 { - let (a0, a1) = self.split_u64x8(a); - let (b0, b1) = self.split_u64x8(b); - self.combine_u64x4(self.xor_u64x4(a0, b0), self.xor_u64x4(a1, b1)) + Bytes::from_bytes(self.xor_u8x64(Bytes::to_bytes(a), Bytes::to_bytes(b))) } #[doc = "Compute the bitwise NOT of the vector."] #[inline(always)] fn not_u64x8(self, a: u64x8) -> u64x8 { - let (a0, a1) = self.split_u64x8(a); - self.combine_u64x4(self.not_u64x4(a0), self.not_u64x4(a1)) + a ^ !0 } #[doc = "Shift each element left by the given number of bits.\n\nBits shifted out of the left side are discarded, and zeros are shifted in on the right.\n\nWhen shifting out of bounds (e.g. shifting a 32-bit value by 32 or more), the result is implementation-defined and may vary by platform."] #[inline(always)] @@ -12011,10 +13416,11 @@ pub trait Simd: #[doc = "Clamp each element to the interval `[b, c]`.\n\nIf `b > c`, or `b` or `c` are NaN, the result is implementation-defined for that lane.\n\nIf `a` is NaN, the result is an implementation-defined non-deterministic NaN value. I.e. the result of the lane will be a NaN value but its exact bit pattern is not specified.\n\nIf one floating-point operand is positive zero and the other is negative zero, the result is implementation-defined, and it could be either one.\n\n# Panics\nPanics with debug assertions if `b > c` for any element or any element of `b` or `c` is NaN."] #[inline(always)] fn clamp_u64x8(self, a: u64x8, b: u64x8, c: u64x8) -> u64x8 { - let (a0, a1) = self.split_u64x8(a); - let (b0, b1) = self.split_u64x8(b); - let (c0, c1) = self.split_u64x8(c); - self.combine_u64x4(self.clamp_u64x4(a0, b0, c0), self.clamp_u64x4(a1, b1, c1)) + debug_assert!( + b.simd_le(c).all_true(), + "clamp requires min <= max for all elements" + ); + a.max(b).min(c) } #[doc = "Compare two vectors element-wise for equality.\n\nReturns a mask where each logical lane is true if the corresponding elements are equal, and false if not."] #[inline(always)] @@ -12173,53 +13579,63 @@ pub trait Simd: lo | (hi << 4usize) } #[doc = "Create a SIMD mask from an integer vector of the same width.\n\nA lane value of -1 means \"true\", a lane value of 0 means \"false\", and all other lane values result in unspecified behavior."] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8; + #[inline(always)] + fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { + mask64x8 { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } #[doc = "Convert a SIMD mask to an integer vector of the same width.\n\n\"True\" maps to -1 and \"false\" maps to 0."] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8; + #[inline(always)] + fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { + i64x8 { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } #[doc = "Set one logical lane of a SIMD mask."] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> (); #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_left_mask64x8( self, a: mask64x8, - ) -> mask64x8; + ) -> mask64x8 { + mask64x8::from_vector(a.to_vector().rotate_elements_left::()) + } #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] + #[inline(always)] fn rotate_elements_right_mask64x8( self, a: mask64x8, - ) -> mask64x8; + ) -> mask64x8 { + mask64x8::from_vector(a.to_vector().rotate_elements_right::()) + } #[doc = "Compute the logical AND of two masks."] #[inline(always)] fn and_mask64x8(self, a: mask64x8, b: mask64x8) -> mask64x8 { - let (a0, a1) = self.split_mask64x8(a); - let (b0, b1) = self.split_mask64x8(b); - self.combine_mask64x4(self.and_mask64x4(a0, b0), self.and_mask64x4(a1, b1)) + mask64x8::from_vector(a.to_vector() & b.to_vector()) } #[doc = "Compute the logical OR of two masks."] #[inline(always)] fn or_mask64x8(self, a: mask64x8, b: mask64x8) -> mask64x8 { - let (a0, a1) = self.split_mask64x8(a); - let (b0, b1) = self.split_mask64x8(b); - self.combine_mask64x4(self.or_mask64x4(a0, b0), self.or_mask64x4(a1, b1)) + mask64x8::from_vector(a.to_vector() | b.to_vector()) } #[doc = "Compute the logical XOR of two masks."] #[inline(always)] fn xor_mask64x8(self, a: mask64x8, b: mask64x8) -> mask64x8 { - let (a0, a1) = self.split_mask64x8(a); - let (b0, b1) = self.split_mask64x8(b); - self.combine_mask64x4(self.xor_mask64x4(a0, b0), self.xor_mask64x4(a1, b1)) + mask64x8::from_vector(a.to_vector() ^ b.to_vector()) } #[doc = "Compute the logical NOT of the mask."] #[inline(always)] fn not_mask64x8(self, a: mask64x8) -> mask64x8 { - let (a0, a1) = self.split_mask64x8(a); - self.combine_mask64x4(self.not_mask64x4(a0), self.not_mask64x4(a1)) + mask64x8::from_vector(!a.to_vector()) } #[doc = "Reverse the order of the mask's logical lanes."] #[inline(always)] fn reverse_mask64x8(self, a: mask64x8) -> mask64x8 { - let (a0, a1) = self.split_mask64x8(a); - self.combine_mask64x4(self.reverse_mask64x4(a1), self.reverse_mask64x4(a0)) + mask64x8::from_vector(a.to_vector().reverse()) } #[doc = "Select elements from `b` and `c` based on the mask operand `a`.\n\nThis operation's behavior is unspecified if a was constructed from signed integer lanes that are neither all-zeroes (integer value 0) nor all-ones (integer value -1). See the [`Select`] trait's documentation for more information."] #[inline(always)] @@ -12626,17 +14042,30 @@ pub trait SimdBase: + IntoIterator + AsRef<[Self::Element]> + AsMut<[Self::Element]> + + for<'a> TryFrom<&'a [Self::Element]> + From; - fn as_slice(&self) -> &[Self::Element]; - fn as_mut_slice(&mut self) -> &mut [Self::Element]; + #[inline(always)] + fn as_slice(&self) -> &[Self::Element] { + self.as_array().as_ref() + } + #[inline(always)] + fn as_mut_slice(&mut self) -> &mut [Self::Element] { + self.as_mut_array().as_mut() + } #[doc = r" Create a SIMD vector from a slice."] #[doc = r""] #[doc = r" The slice must be exactly the size of the SIMD vector."] - fn from_slice(simd: S, slice: &[Self::Element]) -> Self; + #[inline(always)] + fn from_slice(simd: S, slice: &[Self::Element]) -> Self { + Self::load_array(simd, slice.try_into().unwrap_or_else(|_| unreachable!())) + } #[doc = r" Store a SIMD vector into a slice."] #[doc = r""] #[doc = r" The slice must be exactly the size of the SIMD vector."] - fn store_slice(&self, slice: &mut [Self::Element]); + #[inline(always)] + fn store_slice(&self, slice: &mut [Self::Element]) { + slice.copy_from_slice(self.as_array().as_ref()); + } #[doc = r" Create a SIMD vector from its corresponding lane array."] #[inline(always)] fn load_array(simd: S, val: Self::Array) -> Self { @@ -12972,7 +14401,10 @@ pub trait SimdBase: #[doc = "Compute the absolute value of each element.\n\nUnsigned integers are unchanged. Signed integers use wrapping absolute value: the minimum representable value remains unchanged. This matches `i32::abs()`.\n\nFor floating-point elements, clear the sign bit, preserving all other bits. For example, negative zero becomes positive zero."] fn abs(self) -> Self; #[doc = "Create a SIMD vector with all elements set to the given value."] - fn splat(simd: S, val: Self::Element) -> Self; + #[inline(always)] + fn splat(simd: S, val: Self::Element) -> Self { + Self::simd_from(simd, val) + } #[doc = "Reverse the order of the vector's elements."] fn reverse(self) -> Self; #[doc = "Concatenate `[self, rhs]` and extract `Self::LEN` elements starting at index `SHIFT`.\n\n`SHIFT` must be within [0, `Self::LEN`].\n\nThis can be used to implement a \"shift items\" operation by providing all zeroes as one operand. For a left shift, the right-hand side should be all zeroes. For a right shift by `M` items, the left-hand side should be all zeroes, and the shift amount will be `Self::LEN - M`.\n\nThis can also be used to rotate items within a vector by providing the same vector as both operands.\n\n```text\n\nslide::<1>([a b c d], [e f g h]) == [b c d e]\n\n```"] @@ -13276,11 +14708,17 @@ pub trait SimdMask: #[doc = r" Create a SIMD mask from signed integer mask lanes."] #[doc = r""] #[doc = r" The slice must be exactly the size of the SIMD mask."] - fn from_slice(simd: S, slice: &[Self::Element]) -> Self; + #[inline(always)] + fn from_slice(simd: S, slice: &[Self::Element]) -> Self { + Self::from_vector(Self::Ints::from_slice(simd, slice)) + } #[doc = r" Store this SIMD mask as signed integer mask lanes."] #[doc = r""] #[doc = r" The slice must be exactly the size of the SIMD mask."] - fn store_slice(&self, slice: &mut [Self::Element]); + #[inline(always)] + fn store_slice(&self, slice: &mut [Self::Element]) { + self.to_vector().store_slice(slice); + } #[doc = "Rotate the mask elements to the left by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] fn rotate_elements_left(self) -> Self; #[doc = "Rotate the mask elements to the right by `OFFSET`.\n\nIf `OFFSET` is greater than or equal to `Self::LEN`, it wraps modulo `Self::LEN`."] diff --git a/fearless_simd/src/generated/simd_types.rs b/fearless_simd/src/generated/simd_types.rs index 8a8f3014..18d079cc 100644 --- a/fearless_simd/src/generated/simd_types.rs +++ b/fearless_simd/src/generated/simd_types.rs @@ -106,26 +106,6 @@ impl SimdBase for f32x4 { type Block = f32x4; type Array = [f32; 4]; #[inline(always)] - fn as_slice(&self) -> &[f32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [f32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[f32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [f32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: f32) -> Self { - simd.splat_f32x4(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -535,26 +515,6 @@ impl SimdBase for i8x16 { type Block = i8x16; type Array = [i8; 16]; #[inline(always)] - fn as_slice(&self) -> &[i8] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i8] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i8]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i8]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i8) -> Self { - simd.splat_i8x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -922,26 +882,6 @@ impl SimdBase for u8x16 { type Block = u8x16; type Array = [u8; 16]; #[inline(always)] - fn as_slice(&self) -> &[u8] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u8] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u8]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u8]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u8) -> Self { - simd.splat_u8x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -1287,16 +1227,6 @@ impl SimdMask for mask8x16 { self.simd.set_mask8x16(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i8]) -> Self { - let slice: &[i8; 16] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i8]) { - let slice: &mut [i8; 16] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask8x16::(self) } @@ -1452,26 +1382,6 @@ impl SimdBase for i16x8 { type Block = i16x8; type Array = [i16; 8]; #[inline(always)] - fn as_slice(&self) -> &[i16] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i16] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i16]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i16]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i16) -> Self { - simd.splat_i16x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -1846,26 +1756,6 @@ impl SimdBase for u16x8 { type Block = u16x8; type Array = [u16; 8]; #[inline(always)] - fn as_slice(&self) -> &[u16] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u16] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u16]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u16]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u16) -> Self { - simd.splat_u16x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -2218,16 +2108,6 @@ impl SimdMask for mask16x8 { self.simd.set_mask16x8(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i16]) -> Self { - let slice: &[i16; 8] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i16]) { - let slice: &mut [i16; 8] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask16x8::(self) } @@ -2390,26 +2270,6 @@ impl SimdBase for i32x4 { type Block = i32x4; type Array = [i32; 4]; #[inline(always)] - fn as_slice(&self) -> &[i32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i32) -> Self { - simd.splat_i32x4(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -2784,26 +2644,6 @@ impl SimdBase for u32x4 { type Block = u32x4; type Array = [u32; 4]; #[inline(always)] - fn as_slice(&self) -> &[u32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u32) -> Self { - simd.splat_u32x4(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -3156,16 +2996,6 @@ impl SimdMask for mask32x4 { self.simd.set_mask32x4(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i32]) -> Self { - let slice: &[i32; 4] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i32]) { - let slice: &mut [i32; 4] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask32x4::(self) } @@ -3321,26 +3151,6 @@ impl SimdBase for f64x2 { type Block = f64x2; type Array = [f64; 2]; #[inline(always)] - fn as_slice(&self) -> &[f64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [f64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[f64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [f64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: f64) -> Self { - simd.splat_f64x2(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -3758,26 +3568,6 @@ impl SimdBase for i64x2 { type Block = i64x2; type Array = [i64; 2]; #[inline(always)] - fn as_slice(&self) -> &[i64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i64) -> Self { - simd.splat_i64x2(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -4126,26 +3916,6 @@ impl SimdBase for u64x2 { type Block = u64x2; type Array = [u64; 2]; #[inline(always)] - fn as_slice(&self) -> &[u64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u64) -> Self { - simd.splat_u64x2(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block } @@ -4472,16 +4242,6 @@ impl SimdMask for mask64x2 { self.simd.set_mask64x2(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i64]) -> Self { - let slice: &[i64; 2] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i64]) { - let slice: &mut [i64; 2] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask64x2::(self) } @@ -4623,26 +4383,6 @@ impl SimdBase for f32x8 { type Block = f32x4; type Array = [f32; 8]; #[inline(always)] - fn as_slice(&self) -> &[f32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [f32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[f32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [f32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: f32) -> Self { - simd.splat_f32x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_f32x4(block, block) } @@ -5059,26 +4799,6 @@ impl SimdBase for i8x32 { type Block = i8x16; type Array = [i8; 32]; #[inline(always)] - fn as_slice(&self) -> &[i8] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i8] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i8]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i8]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i8) -> Self { - simd.splat_i8x32(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_i8x16(block, block) } @@ -5457,26 +5177,6 @@ impl SimdBase for u8x32 { type Block = u8x16; type Array = [u8; 32]; #[inline(always)] - fn as_slice(&self) -> &[u8] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u8] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u8]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u8]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u8) -> Self { - simd.splat_u8x32(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_u8x16(block, block) } @@ -5833,16 +5533,6 @@ impl SimdMask for mask8x32 { self.simd.set_mask8x32(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i8]) -> Self { - let slice: &[i8; 32] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i8]) { - let slice: &mut [i8; 32] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask8x32::(self) } @@ -5991,26 +5681,6 @@ impl SimdBase for i16x16 { type Block = i16x8; type Array = [i16; 16]; #[inline(always)] - fn as_slice(&self) -> &[i16] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i16] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i16]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i16]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i16) -> Self { - simd.splat_i16x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_i16x8(block, block) } @@ -6391,26 +6061,6 @@ impl SimdBase for u16x16 { type Block = u16x8; type Array = [u16; 16]; #[inline(always)] - fn as_slice(&self) -> &[u16] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u16] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u16]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u16]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u16) -> Self { - simd.splat_u16x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_u16x8(block, block) } @@ -6769,16 +6419,6 @@ impl SimdMask for mask16x16 { self.simd.set_mask16x16(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i16]) -> Self { - let slice: &[i16; 16] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i16]) { - let slice: &mut [i16; 16] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask16x16::(self) } @@ -6941,26 +6581,6 @@ impl SimdBase for i32x8 { type Block = i32x4; type Array = [i32; 8]; #[inline(always)] - fn as_slice(&self) -> &[i32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i32) -> Self { - simd.splat_i32x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_i32x4(block, block) } @@ -7342,26 +6962,6 @@ impl SimdBase for u32x8 { type Block = u32x4; type Array = [u32; 8]; #[inline(always)] - fn as_slice(&self) -> &[u32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u32) -> Self { - simd.splat_u32x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_u32x4(block, block) } @@ -7721,16 +7321,6 @@ impl SimdMask for mask32x8 { self.simd.set_mask32x8(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i32]) -> Self { - let slice: &[i32; 8] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i32]) { - let slice: &mut [i32; 8] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask32x8::(self) } @@ -7893,26 +7483,6 @@ impl SimdBase for f64x4 { type Block = f64x2; type Array = [f64; 4]; #[inline(always)] - fn as_slice(&self) -> &[f64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [f64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[f64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [f64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: f64) -> Self { - simd.splat_f64x4(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_f64x2(block, block) } @@ -8325,26 +7895,6 @@ impl SimdBase for i64x4 { type Block = i64x2; type Array = [i64; 4]; #[inline(always)] - fn as_slice(&self) -> &[i64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i64) -> Self { - simd.splat_i64x4(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_i64x2(block, block) } @@ -8688,26 +8238,6 @@ impl SimdBase for u64x4 { type Block = u64x2; type Array = [u64; 4]; #[inline(always)] - fn as_slice(&self) -> &[u64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u64) -> Self { - simd.splat_u64x4(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { block.simd.combine_u64x2(block, block) } @@ -9029,16 +8559,6 @@ impl SimdMask for mask64x4 { self.simd.set_mask64x4(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i64]) -> Self { - let slice: &[i64; 4] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i64]) { - let slice: &mut [i64; 4] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask64x4::(self) } @@ -9187,26 +8707,6 @@ impl SimdBase for f32x16 { type Block = f32x4; type Array = [f32; 16]; #[inline(always)] - fn as_slice(&self) -> &[f32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [f32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[f32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [f32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: f32) -> Self { - simd.splat_f32x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_f32x4(block, block); block2.simd.combine_f32x8(block2, block2) @@ -9626,26 +9126,6 @@ impl SimdBase for i8x64 { type Block = i8x16; type Array = [i8; 64]; #[inline(always)] - fn as_slice(&self) -> &[i8] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i8] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i8]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i8]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i8) -> Self { - simd.splat_i8x64(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_i8x16(block, block); block2.simd.combine_i8x32(block2, block2) @@ -10050,26 +9530,6 @@ impl SimdBase for u8x64 { type Block = u8x16; type Array = [u8; 64]; #[inline(always)] - fn as_slice(&self) -> &[u8] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u8] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u8]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u8]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u8) -> Self { - simd.splat_u8x64(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_u8x16(block, block); block2.simd.combine_u8x32(block2, block2) @@ -10452,16 +9912,6 @@ impl SimdMask for mask8x64 { self.simd.set_mask8x64(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i8]) -> Self { - let slice: &[i8; 64] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i8]) { - let slice: &mut [i8; 64] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask8x64::(self) } @@ -10603,26 +10053,6 @@ impl SimdBase for i16x32 { type Block = i16x8; type Array = [i16; 32]; #[inline(always)] - fn as_slice(&self) -> &[i16] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i16] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i16]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i16]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i16) -> Self { - simd.splat_i16x32(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_i16x8(block, block); block2.simd.combine_i16x16(block2, block2) @@ -11013,26 +10443,6 @@ impl SimdBase for u16x32 { type Block = u16x8; type Array = [u16; 32]; #[inline(always)] - fn as_slice(&self) -> &[u16] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u16] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u16]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u16]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u16) -> Self { - simd.splat_u16x32(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_u16x8(block, block); block2.simd.combine_u16x16(block2, block2) @@ -11401,16 +10811,6 @@ impl SimdMask for mask16x32 { self.simd.set_mask16x32(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i16]) -> Self { - let slice: &[i16; 32] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i16]) { - let slice: &mut [i16; 32] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask16x32::(self) } @@ -11566,26 +10966,6 @@ impl SimdBase for i32x16 { type Block = i32x4; type Array = [i32; 16]; #[inline(always)] - fn as_slice(&self) -> &[i32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i32) -> Self { - simd.splat_i32x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_i32x4(block, block); block2.simd.combine_i32x8(block2, block2) @@ -11972,26 +11352,6 @@ impl SimdBase for u32x16 { type Block = u32x4; type Array = [u32; 16]; #[inline(always)] - fn as_slice(&self) -> &[u32] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u32] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u32]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u32]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u32) -> Self { - simd.splat_u32x16(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_u32x4(block, block); block2.simd.combine_u32x8(block2, block2) @@ -12356,16 +11716,6 @@ impl SimdMask for mask32x16 { self.simd.set_mask32x16(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i32]) -> Self { - let slice: &[i32; 16] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i32]) { - let slice: &mut [i32; 16] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask32x16::(self) } @@ -12528,26 +11878,6 @@ impl SimdBase for f64x8 { type Block = f64x2; type Array = [f64; 8]; #[inline(always)] - fn as_slice(&self) -> &[f64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [f64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[f64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [f64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: f64) -> Self { - simd.splat_f64x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_f64x2(block, block); block2.simd.combine_f64x4(block2, block2) @@ -12966,26 +12296,6 @@ impl SimdBase for i64x8 { type Block = i64x2; type Array = [i64; 8]; #[inline(always)] - fn as_slice(&self) -> &[i64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [i64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[i64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: i64) -> Self { - simd.splat_i64x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_i64x2(block, block); block2.simd.combine_i64x4(block2, block2) @@ -13335,26 +12645,6 @@ impl SimdBase for u64x8 { type Block = u64x2; type Array = [u64; 8]; #[inline(always)] - fn as_slice(&self) -> &[u64] { - self.as_array().as_slice() - } - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [u64] { - self.as_mut_array().as_mut_slice() - } - #[inline(always)] - fn from_slice(simd: S, slice: &[u64]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [u64]) { - (*self).store_array(slice.try_into().unwrap()); - } - #[inline(always)] - fn splat(simd: S, val: u64) -> Self { - simd.splat_u64x8(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { let block2 = block.simd.combine_u64x2(block, block); block2.simd.combine_u64x4(block2, block2) @@ -13682,16 +12972,6 @@ impl SimdMask for mask64x8 { self.simd.set_mask64x8(self, index, value); } #[inline(always)] - fn from_slice(simd: S, slice: &[i64]) -> Self { - let slice: &[i64; 8] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - #[inline(always)] - fn store_slice(&self, slice: &mut [i64]) { - let slice: &mut [i64; 8] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #[inline(always)] fn rotate_elements_left(self) -> Self { self.simd.rotate_elements_left_mask64x8::(self) } diff --git a/fearless_simd/src/generated/sse2.rs b/fearless_simd/src/generated/sse2.rs index 13701067..d391ad4c 100644 --- a/fearless_simd/src/generated/sse2.rs +++ b/fearless_simd/src/generated/sse2.rs @@ -168,56 +168,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x4( - self, - values: f32x4, - mask: mask32x4, - merge: f32x4, - ) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x4(self, values: f32x4, mask: mask32x4) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x4( - self, - values: f32x4, - mask: mask32x4, - merge: f32x4, - ) -> f32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn neg_f32x4(self, a: f32x4) -> f32x4 { crate::kernel!( #[inline(always)] @@ -638,38 +588,6 @@ impl Simd for Sse2 { a * const { f32::to_radians(1.0) } } #[inline(always)] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { crate::kernel!( #[inline(always)] @@ -916,56 +834,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i8x16(self, a: i8x16) -> i8x16 { [ i8::try_from(a[0usize].count_ones()).unwrap(), @@ -1010,10 +878,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { [ i8::reverse_bits(a[0usize]), @@ -1093,40 +957,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i8x16, b: i8x16) -> i8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i8x16, b: i8x16) -> i8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i8x16, b: i8x16) -> i8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i8x16(self, a: i8x16) -> i8x16 { - a ^ !0 - } - #[inline(always)] fn shl_i8x16(self, a: i8x16, shift: u32) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1374,14 +1204,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -1667,18 +1489,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.add_i16x8(a0, b0), self.add_i16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i8x16(self, a: i8x16) -> i16x8 { [ (a[0usize] as i16) + (a[1usize] as i16), @@ -1693,12 +1503,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { - let (low, high) = self.widening_mul_i8x16(a, b); - let (even, odd) = self.deinterleave_i16x8(low, high); - self.add_i16x8(even, odd) - } - #[inline(always)] fn splat_u8x16(self, val: u8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1873,53 +1677,6 @@ impl Simd for Sse2 { Bytes::from_bytes(result) } #[inline(always)] - fn compress_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16 { - self.compress_merge_u8x16(values, mask, u8x16::splat(self, 0)) - } - #[inline(always)] - fn compress_merge_u8x16( - self, - values: u8x16, - mask: mask8x16, - merge: u8x16, - ) -> u8x16 { - let mask = self.to_bitmask_mask8x16(mask); - let mut merge_padded = [0u8; 16 + 1]; - merge_padded[..16].copy_from_slice(&*merge); - let mut compacted = merge_padded; - let mut output_lane = 0; - for input_lane in 0..16 { - compacted[output_lane] = values[input_lane]; - output_lane += ((mask >> input_lane) & 1) as usize; - } - compacted[output_lane] = merge_padded[output_lane]; - let mut result = merge; - result.copy_from_slice(&compacted[..16]); - result - } - #[inline(always)] - fn expand_u8x16(self, values: u8x16, mask: mask8x16) -> u8x16 { - self.expand_merge_u8x16(values, mask, u8x16::splat(self, 0)) - } - #[inline(always)] - fn expand_merge_u8x16( - self, - values: u8x16, - mask: mask8x16, - merge: u8x16, - ) -> u8x16 { - let mask = self.to_bitmask_mask8x16(mask); - let mut result = merge; - let mut input_lane = 0; - for output_lane in 0..16 { - let bit = ((mask >> output_lane) & 1) as u8; - let keep = 0u8.wrapping_sub(bit); - result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); - input_lane += usize::from(bit); - } - result - } - #[inline(always)] fn count_ones_u8x16(self, a: u8x16) -> u8x16 { [ u8::try_from(a[0usize].count_ones()).unwrap(), @@ -1964,10 +1721,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { [ u8::reverse_bits(a[0usize]), @@ -2077,10 +1830,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn not_u8x16(self, a: u8x16) -> u8x16 { - a ^ !0 - } - #[inline(always)] fn shl_u8x16(self, a: u8x16, shift: u32) -> u8x16 { crate::kernel!( #[inline(always)] @@ -2254,14 +2003,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2551,18 +2292,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.add_u16x8(a0, b0), self.add_u16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u8x16(self, a: u8x16) -> u16x8 { [ (a[0usize] as u16) + (a[1usize] as u16), @@ -2577,12 +2306,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { - let (low, high) = self.widening_mul_u8x16(a, b); - let (even, odd) = self.deinterleave_u16x8(low, high); - self.add_u16x8(even, odd) - } - #[inline(always)] fn splat_mask8x16(self, val: bool) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2626,20 +2349,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { - mask8x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { - i8x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -2651,82 +2360,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask8x16(self, a: mask8x16) -> mask8x16 { - self.xor_mask8x16(a, self.splat_mask8x16(true)) - } - #[inline(always)] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { - let lanes = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i8x16(lanes); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask8x16( self, a: mask8x16, @@ -2869,56 +2502,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x8( - self, - values: i16x8, - mask: mask16x8, - merge: i16x8, - ) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x8(self, values: i16x8, mask: mask16x8) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x8( - self, - values: i16x8, - mask: mask16x8, - merge: i16x8, - ) -> i16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i16x8(self, a: i16x8) -> i16x8 { [ i16::try_from(a[0usize].count_ones()).unwrap(), @@ -3025,40 +2608,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i16x8, b: i16x8) -> i16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i16x8, b: i16x8) -> i16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i16x8, b: i16x8) -> i16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x8(self, a: i16x8) -> i16x8 { - a ^ !0 - } - #[inline(always)] fn shl_i16x8(self, a: i16x8, shift: u32) -> i16x8 { crate::kernel!( #[inline(always)] @@ -3197,14 +2746,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3438,12 +2979,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn widening_add_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.add_i32x4(a0, b0), self.add_i32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i16x8(self, a: i16x8) -> i32x4 { crate::kernel!( #[inline(always)] @@ -3530,56 +3065,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x8( - self, - values: u16x8, - mask: mask16x8, - merge: u16x8, - ) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x8(self, values: u16x8, mask: mask16x8) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x8( - self, - values: u16x8, - mask: mask16x8, - merge: u16x8, - ) -> u16x8 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u16x8(self, a: u16x8) -> u16x8 { [ u16::try_from(a[0usize].count_ones()).unwrap(), @@ -3686,65 +3171,31 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { + fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8 { crate::kernel!( #[inline(always)] - fn kernel(token: Sse2, a: u16x8, b: u16x8) -> u16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) + fn kernel(token: Sse2, a: u16x8, shift: u32) -> u16x8 { + _mm_sll_epi16(a.into(), _mm_cvtsi32_si128(shift.cast_signed())).simd_into(token) } ); - kernel(self, a, b) + kernel(self, a, shift) + } + #[inline(always)] + fn shlv_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { + [ + u16::wrapping_shl(a[0usize], b[0usize] as u32), + u16::wrapping_shl(a[1usize], b[1usize] as u32), + u16::wrapping_shl(a[2usize], b[2usize] as u32), + u16::wrapping_shl(a[3usize], b[3usize] as u32), + u16::wrapping_shl(a[4usize], b[4usize] as u32), + u16::wrapping_shl(a[5usize], b[5usize] as u32), + u16::wrapping_shl(a[6usize], b[6usize] as u32), + u16::wrapping_shl(a[7usize], b[7usize] as u32), + ] + .simd_into(self) } #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u16x8, b: u16x8) -> u16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u16x8, b: u16x8) -> u16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x8(self, a: u16x8) -> u16x8 { - a ^ !0 - } - #[inline(always)] - fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u16x8, shift: u32) -> u16x8 { - _mm_sll_epi16(a.into(), _mm_cvtsi32_si128(shift.cast_signed())).simd_into(token) - } - ); - kernel(self, a, shift) - } - #[inline(always)] - fn shlv_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - [ - u16::wrapping_shl(a[0usize], b[0usize] as u32), - u16::wrapping_shl(a[1usize], b[1usize] as u32), - u16::wrapping_shl(a[2usize], b[2usize] as u32), - u16::wrapping_shl(a[3usize], b[3usize] as u32), - u16::wrapping_shl(a[4usize], b[4usize] as u32), - u16::wrapping_shl(a[5usize], b[5usize] as u32), - u16::wrapping_shl(a[6usize], b[6usize] as u32), - u16::wrapping_shl(a[7usize], b[7usize] as u32), - ] - .simd_into(self) - } - #[inline(always)] - fn shr_u16x8(self, a: u16x8, shift: u32) -> u16x8 { + fn shr_u16x8(self, a: u16x8, shift: u32) -> u16x8 { crate::kernel!( #[inline(always)] fn kernel(token: Sse2, a: u16x8, shift: u32) -> u16x8 { @@ -3952,14 +3403,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -4197,12 +3640,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4 { crate::kernel!( #[inline(always)] @@ -4220,12 +3657,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { - let (low, high) = self.widening_mul_u16x8(a, b); - let (even, odd) = self.deinterleave_u32x4(low, high); - self.add_u32x4(even, odd) - } - #[inline(always)] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -4309,20 +3740,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { - mask16x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { - i16x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -4334,82 +3751,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask16x8(self, a: mask16x8) -> mask16x8 { - self.xor_mask16x8(a, self.splat_mask16x8(true)) - } - #[inline(always)] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { - let lanes = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i16x8(lanes); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask16x8( self, a: mask16x8, @@ -4555,56 +3896,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x4( - self, - values: i32x4, - mask: mask32x4, - merge: i32x4, - ) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x4(self, values: i32x4, mask: mask32x4) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x4( - self, - values: i32x4, - mask: mask32x4, - merge: i32x4, - ) -> i32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i32x4(self, a: i32x4) -> i32x4 { [ a[0usize].count_ones().cast_signed(), @@ -4695,40 +3986,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i32x4, b: i32x4) -> i32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i32x4, b: i32x4) -> i32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i32x4, b: i32x4) -> i32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x4(self, a: i32x4) -> i32x4 { - a ^ !0 - } - #[inline(always)] fn shl_i32x4(self, a: i32x4, shift: u32) -> i32x4 { crate::kernel!( #[inline(always)] @@ -4888,14 +4145,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -5116,18 +4365,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn widening_mul_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.mul_i64x2(a0, b0), self.mul_i64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2 { crate::kernel!( #[inline(always)] @@ -5145,12 +4382,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { - let (low, high) = self.widening_mul_i32x4(a, b); - let (even, odd) = self.deinterleave_i64x2(low, high); - self.add_i64x2(even, odd) - } - #[inline(always)] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8 { [ a[0usize] as i16, @@ -5226,56 +4457,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x4( - self, - values: u32x4, - mask: mask32x4, - merge: u32x4, - ) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x4(self, values: u32x4, mask: mask32x4) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x4( - self, - values: u32x4, - mask: mask32x4, - merge: u32x4, - ) -> u32x4 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u32x4(self, a: u32x4) -> u32x4 { [ a[0usize].count_ones(), @@ -5366,40 +4547,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u32x4, b: u32x4) -> u32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u32x4, b: u32x4) -> u32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u32x4, b: u32x4) -> u32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x4(self, a: u32x4) -> u32x4 { - a ^ !0 - } - #[inline(always)] fn shl_u32x4(self, a: u32x4, shift: u32) -> u32x4 { crate::kernel!( #[inline(always)] @@ -5589,14 +4736,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -5821,18 +4960,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2 { crate::kernel!( #[inline(always)] @@ -5850,12 +4977,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { - let (low, high) = self.widening_mul_u32x4(a, b); - let (even, odd) = self.deinterleave_u64x2(low, high); - self.add_u64x2(even, odd) - } - #[inline(always)] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8 { [ a[0usize] as u16, @@ -5941,20 +5062,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { - mask32x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { - i32x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -5966,111 +5073,35 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x4( + fn select_mask32x4( self, a: mask32x4, + b: mask32x4, + c: mask32x4, ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } + crate::kernel!( + #[inline(always)] + fn kernel( + token: Sse2, + a: mask32x4, + b: mask32x4, + c: mask32x4, + ) -> mask32x4 { + _mm_or_si128( + _mm_and_si128(a.into(), b.into()), + _mm_andnot_si128(a.into(), c.into()), + ) + .simd_into(token) + } + ); + kernel(self, a, b, c) } #[inline(always)] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { + fn simd_eq_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { crate::kernel!( #[inline(always)] fn kernel(token: Sse2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask32x4(self, a: mask32x4) -> mask32x4 { - self.xor_mask32x4(a, self.splat_mask32x4(true)) - } - #[inline(always)] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { - let lanes = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i32x4(lanes); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] - fn select_mask32x4( - self, - a: mask32x4, - b: mask32x4, - c: mask32x4, - ) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel( - token: Sse2, - a: mask32x4, - b: mask32x4, - c: mask32x4, - ) -> mask32x4 { - _mm_or_si128( - _mm_and_si128(a.into(), b.into()), - _mm_andnot_si128(a.into(), c.into()), - ) - .simd_into(token) - } - ); - kernel(self, a, b, c) - } - #[inline(always)] - fn simd_eq_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_cmpeq_epi32(a.into(), b.into()).simd_into(token) + _mm_cmpeq_epi32(a.into(), b.into()).simd_into(token) } ); kernel(self, a, b) @@ -6187,56 +5218,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x2( - self, - values: f64x2, - mask: mask64x2, - merge: f64x2, - ) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x2(self, values: f64x2, mask: mask64x2) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x2( - self, - values: f64x2, - mask: mask64x2, - merge: f64x2, - ) -> f64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn neg_f64x2(self, a: f64x2) -> f64x2 { crate::kernel!( #[inline(always)] @@ -6627,38 +5608,6 @@ impl Simd for Sse2 { a * const { f64::to_radians(1.0) } } #[inline(always)] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { crate::kernel!( #[inline(always)] @@ -6840,56 +5789,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x2( - self, - values: i64x2, - mask: mask64x2, - merge: i64x2, - ) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x2(self, values: i64x2, mask: mask64x2) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x2( - self, - values: i64x2, - mask: mask64x2, - merge: i64x2, - ) -> i64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i64x2(self, a: i64x2) -> i64x2 { [ i64::from(a[0usize].count_ones()), @@ -6966,40 +5865,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i64x2, b: i64x2) -> i64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i64x2, b: i64x2) -> i64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: i64x2, b: i64x2) -> i64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x2(self, a: i64x2) -> i64x2 { - a ^ !0 - } - #[inline(always)] fn shl_i64x2(self, a: i64x2, shift: u32) -> i64x2 { crate::kernel!( #[inline(always)] @@ -7096,14 +5961,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7359,56 +6216,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x2( - self, - values: u64x2, - mask: mask64x2, - merge: u64x2, - ) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x2(self, values: u64x2, mask: mask64x2) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x2( - self, - values: u64x2, - mask: mask64x2, - merge: u64x2, - ) -> u64x2 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_u64x2(self, a: u64x2) -> u64x2 { [ u64::from(a[0usize].count_ones()), @@ -7485,40 +6292,6 @@ impl Simd for Sse2 { kernel(self, a, b) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u64x2, b: u64x2) -> u64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u64x2, b: u64x2) -> u64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: u64x2, b: u64x2) -> u64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u64x2(self, a: u64x2) -> u64x2 { - a ^ !0 - } - #[inline(always)] fn shl_u64x2(self, a: u64x2, shift: u32) -> u64x2 { crate::kernel!( #[inline(always)] @@ -7611,14 +6384,6 @@ impl Simd for Sse2 { .simd_into(self) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7863,20 +6628,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { - mask64x2 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { - i64x2 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> () { assert!( index < 2usize, @@ -7888,82 +6639,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask64x2(self, a: mask64x2) -> mask64x2 { - self.xor_mask64x2(a, self.splat_mask64x2(true)) - } - #[inline(always)] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { - let lanes = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i64x2(lanes); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask64x2( self, a: mask64x2, @@ -8080,94 +6755,12 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x8( - self, - values: f32x8, - mask: mask32x8, - merge: f32x8, - ) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x8( - self, - values: f32x8, - mask: mask32x8, - merge: f32x8, - ) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f32x8(self, a: f32x8, b: f32x8) -> mask32x8 { let (a0, a1) = self.split_f32x8(a); let (b0, b1) = self.split_f32x8(b); self.combine_mask32x4(self.simd_ne_f32x4(a0, b0), self.simd_ne_f32x4(a1, b1)) } #[inline(always)] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f32x8(self, a: f32x8, b: f32x8) -> f32x16 { f32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8204,56 +6797,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i8x32(self, a: i8x32, b: i8x32) -> i8x64 { i8x64 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8357,53 +6900,6 @@ impl Simd for Sse2 { Bytes::from_bytes(result) } #[inline(always)] - fn compress_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32 { - self.compress_merge_u8x32(values, mask, u8x32::splat(self, 0)) - } - #[inline(always)] - fn compress_merge_u8x32( - self, - values: u8x32, - mask: mask8x32, - merge: u8x32, - ) -> u8x32 { - let mask = self.to_bitmask_mask8x32(mask); - let mut merge_padded = [0u8; 32 + 1]; - merge_padded[..32].copy_from_slice(&*merge); - let mut compacted = merge_padded; - let mut output_lane = 0; - for input_lane in 0..32 { - compacted[output_lane] = values[input_lane]; - output_lane += ((mask >> input_lane) & 1) as usize; - } - compacted[output_lane] = merge_padded[output_lane]; - let mut result = merge; - result.copy_from_slice(&compacted[..32]); - result - } - #[inline(always)] - fn expand_u8x32(self, values: u8x32, mask: mask8x32) -> u8x32 { - self.expand_merge_u8x32(values, mask, u8x32::splat(self, 0)) - } - #[inline(always)] - fn expand_merge_u8x32( - self, - values: u8x32, - mask: mask8x32, - merge: u8x32, - ) -> u8x32 { - let mask = self.to_bitmask_mask8x32(mask); - let mut result = merge; - let mut input_lane = 0; - for output_lane in 0..32 { - let bit = ((mask >> output_lane) & 1) as u8; - let keep = 0u8.wrapping_sub(bit); - result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); - input_lane += usize::from(bit); - } - result - } - #[inline(always)] fn combine_u8x32(self, a: u8x32, b: u8x32) -> u8x64 { u8x64 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8424,20 +6920,6 @@ impl Simd for Sse2 { ) } #[inline(always)] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { - mask8x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { - i8x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -8449,36 +6931,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x64 { mask8x64 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8515,56 +6967,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i16x16(self, a: i16x16, b: i16x16) -> i16x32 { i16x32 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8601,56 +7003,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u16x16(self, a: u16x16, b: u16x16) -> u16x32 { u16x32 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8684,20 +7036,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { - mask16x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { - i16x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -8709,36 +7047,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x32 { mask16x32 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8775,56 +7083,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x8( - self, - values: i32x8, - mask: mask32x8, - merge: i32x8, - ) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x8( - self, - values: i32x8, - mask: mask32x8, - merge: i32x8, - ) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i32x8(self, a: i32x8, b: i32x8) -> i32x16 { i32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8861,56 +7119,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x8( - self, - values: u32x8, - mask: mask32x8, - merge: u32x8, - ) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x8( - self, - values: u32x8, - mask: mask32x8, - merge: u32x8, - ) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u32x8(self, a: u32x8, b: u32x8) -> u32x16 { u32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8931,20 +7139,6 @@ impl Simd for Sse2 { ) } #[inline(always)] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { - mask32x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { - i32x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -8956,36 +7150,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x16 { mask32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9022,94 +7186,12 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x4( - self, - values: f64x4, - mask: mask64x4, - merge: f64x4, - ) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x4( - self, - values: f64x4, - mask: mask64x4, - merge: f64x4, - ) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f64x4(self, a: f64x4, b: f64x4) -> mask64x4 { let (a0, a1) = self.split_f64x4(a); let (b0, b1) = self.split_f64x4(b); self.combine_mask64x2(self.simd_ne_f64x2(a0, b0), self.simd_ne_f64x2(a1, b1)) } #[inline(always)] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f64x4(self, a: f64x4, b: f64x4) -> f64x8 { f64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9146,56 +7228,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x4( - self, - values: i64x4, - mask: mask64x4, - merge: i64x4, - ) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x4( - self, - values: i64x4, - mask: mask64x4, - merge: i64x4, - ) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i64x4(self, a: i64x4, b: i64x4) -> i64x8 { i64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9232,56 +7264,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x4( - self, - values: u64x4, - mask: mask64x4, - merge: u64x4, - ) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x4( - self, - values: u64x4, - mask: mask64x4, - merge: u64x4, - ) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u64x4(self, a: u64x4, b: u64x4) -> u64x8 { u64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9302,20 +7284,6 @@ impl Simd for Sse2 { ) } #[inline(always)] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { - mask64x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { - i64x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -9327,36 +7295,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x8 { mask64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9393,94 +7331,12 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x16( - self, - values: f32x16, - mask: mask32x16, - merge: f32x16, - ) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x16( - self, - values: f32x16, - mask: mask32x16, - merge: f32x16, - ) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f32x16(self, a: f32x16, b: f32x16) -> mask32x16 { let (a0, a1) = self.split_f32x16(a); let (b0, b1) = self.split_f32x16(b); self.combine_mask32x8(self.simd_ne_f32x8(a0, b0), self.simd_ne_f32x8(a1, b1)) } #[inline(always)] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f32x16(self, a: f32x16) -> (f32x8, f32x8) { ( f32x8 { @@ -9510,56 +7366,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i8x64(self, a: i8x64) -> (i8x32, i8x32) { ( i8x32 { @@ -9656,53 +7462,6 @@ impl Simd for Sse2 { Bytes::from_bytes(result) } #[inline(always)] - fn compress_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64 { - self.compress_merge_u8x64(values, mask, u8x64::splat(self, 0)) - } - #[inline(always)] - fn compress_merge_u8x64( - self, - values: u8x64, - mask: mask8x64, - merge: u8x64, - ) -> u8x64 { - let mask = self.to_bitmask_mask8x64(mask); - let mut merge_padded = [0u8; 64 + 1]; - merge_padded[..64].copy_from_slice(&*merge); - let mut compacted = merge_padded; - let mut output_lane = 0; - for input_lane in 0..64 { - compacted[output_lane] = values[input_lane]; - output_lane += ((mask >> input_lane) & 1) as usize; - } - compacted[output_lane] = merge_padded[output_lane]; - let mut result = merge; - result.copy_from_slice(&compacted[..64]); - result - } - #[inline(always)] - fn expand_u8x64(self, values: u8x64, mask: mask8x64) -> u8x64 { - self.expand_merge_u8x64(values, mask, u8x64::splat(self, 0)) - } - #[inline(always)] - fn expand_merge_u8x64( - self, - values: u8x64, - mask: mask8x64, - merge: u8x64, - ) -> u8x64 { - let mask = self.to_bitmask_mask8x64(mask); - let mut result = merge; - let mut input_lane = 0; - for output_lane in 0..64 { - let bit = ((mask >> output_lane) & 1) as u8; - let keep = 0u8.wrapping_sub(bit); - result[output_lane] = (values[input_lane] & keep) | (result[output_lane] & !keep); - input_lane += usize::from(bit); - } - result - } - #[inline(always)] fn split_u8x64(self, a: u8x64) -> (u8x32, u8x32) { ( u8x32 { @@ -9716,20 +7475,6 @@ impl Simd for Sse2 { ) } #[inline(always)] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { - mask8x64 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { - i8x64 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> () { assert!( index < 64usize, @@ -9741,36 +7486,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask8x64(self, a: mask8x64) -> (mask8x32, mask8x32) { ( mask8x32 { @@ -9800,56 +7515,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i16x32(self, a: i16x32) -> (i16x16, i16x16) { ( i16x16 { @@ -9879,56 +7544,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u16x32(self, a: u16x32) -> (u16x16, u16x16) { ( u16x16 { @@ -9958,20 +7573,6 @@ impl Simd for Sse2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { - mask16x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { - i16x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -9983,36 +7584,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask16x32(self, a: mask16x32) -> (mask16x16, mask16x16) { ( mask16x16 { @@ -10042,56 +7613,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x16( - self, - values: i32x16, - mask: mask32x16, - merge: i32x16, - ) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x16( - self, - values: i32x16, - mask: mask32x16, - merge: i32x16, - ) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i32x16(self, a: i32x16) -> (i32x8, i32x8) { ( i32x8 { @@ -10121,56 +7642,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x16( - self, - values: u32x16, - mask: mask32x16, - merge: u32x16, - ) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x16( - self, - values: u32x16, - mask: mask32x16, - merge: u32x16, - ) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u32x16(self, a: u32x16) -> (u32x8, u32x8) { ( u32x8 { @@ -10184,20 +7655,6 @@ impl Simd for Sse2 { ) } #[inline(always)] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { - mask32x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { - i32x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -10209,36 +7666,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask32x16(self, a: mask32x16) -> (mask32x8, mask32x8) { ( mask32x8 { @@ -10268,94 +7695,12 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x8( - self, - values: f64x8, - mask: mask64x8, - merge: f64x8, - ) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x8( - self, - values: f64x8, - mask: mask64x8, - merge: f64x8, - ) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f64x8(self, a: f64x8, b: f64x8) -> mask64x8 { let (a0, a1) = self.split_f64x8(a); let (b0, b1) = self.split_f64x8(b); self.combine_mask64x4(self.simd_ne_f64x4(a0, b0), self.simd_ne_f64x4(a1, b1)) } #[inline(always)] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f64x8(self, a: f64x8) -> (f64x4, f64x4) { ( f64x4 { @@ -10385,56 +7730,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x8( - self, - values: i64x8, - mask: mask64x8, - merge: i64x8, - ) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x8( - self, - values: i64x8, - mask: mask64x8, - merge: i64x8, - ) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i64x8(self, a: i64x8) -> (i64x4, i64x4) { ( i64x4 { @@ -10464,56 +7759,6 @@ impl Simd for Sse2 { }) } #[inline(always)] - fn compress_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x8( - self, - values: u64x8, - mask: mask64x8, - merge: u64x8, - ) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x8( - self, - values: u64x8, - mask: mask64x8, - merge: u64x8, - ) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u64x8(self, a: u64x8) -> (u64x4, u64x4) { ( u64x4 { @@ -10527,20 +7772,6 @@ impl Simd for Sse2 { ) } #[inline(always)] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { - mask64x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { - i64x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -10552,36 +7783,6 @@ impl Simd for Sse2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask64x8(self, a: mask64x8) -> (mask64x4, mask64x4) { ( mask64x4 { diff --git a/fearless_simd/src/generated/sse4_2.rs b/fearless_simd/src/generated/sse4_2.rs index e22afd37..d20a781e 100644 --- a/fearless_simd/src/generated/sse4_2.rs +++ b/fearless_simd/src/generated/sse4_2.rs @@ -617,38 +617,6 @@ impl Simd for Sse4_2 { a * const { f32::to_radians(1.0) } } #[inline(always)] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { crate::kernel!( #[inline(always)] @@ -876,56 +844,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x16(self, values: i8x16, mask: mask8x16) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x16(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x16( - self, - values: i8x16, - mask: mask8x16, - merge: i8x16, - ) -> i8x16 { - let mask = mask8x16 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x16( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn count_ones_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -945,14 +863,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { - self.count_ones_i8x16(self.not_i8x16(a)) - } - #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1034,40 +944,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i8x16, b: i8x16) -> i8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i8x16, b: i8x16) -> i8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i8x16, b: i8x16) -> i8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i8x16(self, a: i8x16) -> i8x16 { - a ^ !0 - } - #[inline(always)] fn shl_i8x16(self, a: i8x16, shift: u32) -> i8x16 { crate::kernel!( #[inline(always)] @@ -1247,14 +1123,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -1494,18 +1362,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.add_i16x8(a0, b0), self.add_i16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i8x16(self, a: i8x16) -> i16x8 { crate::kernel!( #[inline(always)] @@ -1516,12 +1372,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { - let (low, high) = self.widening_mul_i8x16(a, b); - let (even, odd) = self.deinterleave_i16x8(low, high); - self.add_i16x8(even, odd) - } - #[inline(always)] fn splat_u8x16(self, val: u8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1759,14 +1609,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { - self.count_ones_u8x16(self.not_u8x16(a)) - } - #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { crate::kernel!( #[inline(always)] @@ -1878,10 +1720,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn not_u8x16(self, a: u8x16) -> u8x16 { - a ^ !0 - } - #[inline(always)] fn shl_u8x16(self, a: u8x16, shift: u32) -> u8x16 { crate::kernel!( #[inline(always)] @@ -2055,14 +1893,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2298,18 +2128,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.add_u16x8(a0, b0), self.add_u16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u8x16(self, a: u8x16) -> u16x8 { crate::kernel!( #[inline(always)] @@ -2320,12 +2138,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { - let (low, high) = self.widening_mul_u8x16(a, b); - let (even, odd) = self.deinterleave_u16x8(low, high); - self.add_u16x8(even, odd) - } - #[inline(always)] fn splat_mask8x16(self, val: bool) -> mask8x16 { crate::kernel!( #[inline(always)] @@ -2367,20 +2179,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { - mask8x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { - i8x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -2392,82 +2190,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask8x16, b: mask8x16) -> mask8x16 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask8x16(self, a: mask8x16) -> mask8x16 { - self.xor_mask8x16(a, self.splat_mask8x16(true)) - } - #[inline(always)] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { - let lanes = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i8x16(lanes); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask8x16( self, a: mask8x16, @@ -2657,10 +2379,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { - self.count_ones_i16x8(self.not_i16x8(a)) - } - #[inline(always)] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8 { let indexes = >::simd_from(self, [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]); @@ -2739,40 +2457,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i16x8, b: i16x8) -> i16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i16x8, b: i16x8) -> i16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i16x8, b: i16x8) -> i16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i16x8(self, a: i16x8) -> i16x8 { - a ^ !0 - } - #[inline(always)] fn shl_i16x8(self, a: i16x8, shift: u32) -> i16x8 { crate::kernel!( #[inline(always)] @@ -2911,14 +2595,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3158,18 +2834,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn widening_mul_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.mul_i32x4(a0, b0), self.mul_i32x4(a1, b1)) - } - #[inline(always)] - fn widening_add_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.add_i32x4(a0, b0), self.add_i32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i16x8(self, a: i16x8) -> i32x4 { crate::kernel!( #[inline(always)] @@ -3311,10 +2975,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { - self.count_ones_u16x8(self.not_u16x8(a)) - } - #[inline(always)] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8 { let indexes = >::simd_from(self, [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]); @@ -3393,40 +3053,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u16x8, b: u16x8) -> u16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u16x8, b: u16x8) -> u16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u16x8, b: u16x8) -> u16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u16x8(self, a: u16x8) -> u16x8 { - a ^ !0 - } - #[inline(always)] fn shl_u16x8(self, a: u16x8, shift: u32) -> u16x8 { crate::kernel!( #[inline(always)] @@ -3565,14 +3191,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -3828,12 +3446,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4 { crate::kernel!( #[inline(always)] @@ -3851,12 +3463,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { - let (low, high) = self.widening_mul_u16x8(a, b); - let (even, odd) = self.deinterleave_u32x4(low, high); - self.add_u32x4(even, odd) - } - #[inline(always)] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16 { crate::kernel!( #[inline(always)] @@ -3939,20 +3545,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { - mask16x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { - i16x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -3964,87 +3556,11 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x8( + fn select_mask16x8( self, a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask16x8, b: mask16x8) -> mask16x8 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask16x8(self, a: mask16x8) -> mask16x8 { - self.xor_mask16x8(a, self.splat_mask16x8(true)) - } - #[inline(always)] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { - let lanes = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i16x8(lanes); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] - fn select_mask16x8( - self, - a: mask16x8, - b: mask16x8, - c: mask16x8, + b: mask16x8, + c: mask16x8, ) -> mask16x8 { crate::kernel!( #[inline(always)] @@ -4243,10 +3759,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { - self.count_ones_i32x4(self.not_i32x4(a)) - } - #[inline(always)] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4 { let indexes = >::simd_from(self, [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); @@ -4345,40 +3857,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i32x4, b: i32x4) -> i32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i32x4, b: i32x4) -> i32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i32x4, b: i32x4) -> i32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i32x4(self, a: i32x4) -> i32x4 { - a ^ !0 - } - #[inline(always)] fn shl_i32x4(self, a: i32x4, shift: u32) -> i32x4 { crate::kernel!( #[inline(always)] @@ -4498,14 +3976,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -4738,12 +4208,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2 { crate::kernel!( #[inline(always)] @@ -4761,12 +4225,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { - let (low, high) = self.widening_mul_i32x4(a, b); - let (even, odd) = self.deinterleave_i64x2(low, high); - self.add_i64x2(even, odd) - } - #[inline(always)] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8 { crate::kernel!( #[inline(always)] @@ -4902,10 +4360,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { - self.count_ones_u32x4(self.not_u32x4(a)) - } - #[inline(always)] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4 { let indexes = >::simd_from(self, [3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12]); @@ -4989,40 +4443,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u32x4, b: u32x4) -> u32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u32x4, b: u32x4) -> u32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u32x4, b: u32x4) -> u32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u32x4(self, a: u32x4) -> u32x4 { - a ^ !0 - } - #[inline(always)] fn shl_u32x4(self, a: u32x4, shift: u32) -> u32x4 { crate::kernel!( #[inline(always)] @@ -5142,14 +4562,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { crate::kernel!( #[inline(always)] @@ -5357,18 +4769,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2 { crate::kernel!( #[inline(always)] @@ -5386,12 +4786,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { - let (low, high) = self.widening_mul_u32x4(a, b); - let (even, odd) = self.deinterleave_u64x2(low, high); - self.add_u64x2(even, odd) - } - #[inline(always)] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8 { crate::kernel!( #[inline(always)] @@ -5490,20 +4884,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { - mask32x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { - i32x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -5515,82 +4895,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask32x4, b: mask32x4) -> mask32x4 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask32x4(self, a: mask32x4) -> mask32x4 { - self.xor_mask32x4(a, self.splat_mask32x4(true)) - } - #[inline(always)] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { - let lanes = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i32x4(lanes); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask32x4( self, a: mask32x4, @@ -6157,38 +5461,6 @@ impl Simd for Sse4_2 { a * const { f64::to_radians(1.0) } } #[inline(always)] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { crate::kernel!( #[inline(always)] @@ -6436,10 +5708,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { - self.count_ones_i64x2(self.not_i64x2(a)) - } - #[inline(always)] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2 { let indexes = >::simd_from(self, [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]); @@ -6546,40 +5814,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i64x2, b: i64x2) -> i64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i64x2, b: i64x2) -> i64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: i64x2, b: i64x2) -> i64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_i64x2(self, a: i64x2) -> i64x2 { - a ^ !0 - } - #[inline(always)] fn shl_i64x2(self, a: i64x2, shift: u32) -> i64x2 { crate::kernel!( #[inline(always)] @@ -6696,14 +5930,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7045,10 +6271,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { - self.count_ones_u64x2(self.not_u64x2(a)) - } - #[inline(always)] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2 { let indexes = >::simd_from(self, [7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8]); @@ -7147,40 +6369,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u64x2, b: u64x2) -> u64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u64x2, b: u64x2) -> u64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: u64x2, b: u64x2) -> u64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_u64x2(self, a: u64x2) -> u64x2 { - a ^ !0 - } - #[inline(always)] fn shl_u64x2(self, a: u64x2, shift: u32) -> u64x2 { crate::kernel!( #[inline(always)] @@ -7303,14 +6491,6 @@ impl Simd for Sse4_2 { kernel(self, a, b) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { crate::kernel!( #[inline(always)] @@ -7603,20 +6783,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { - mask64x2 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { - i64x2 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> () { assert!( index < 2usize, @@ -7628,82 +6794,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_and_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_or_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - crate::kernel!( - #[inline(always)] - fn kernel(token: Sse4_2, a: mask64x2, b: mask64x2) -> mask64x2 { - _mm_xor_si128(a.into(), b.into()).simd_into(token) - } - ); - kernel(self, a, b) - } - #[inline(always)] - fn not_mask64x2(self, a: mask64x2) -> mask64x2 { - self.xor_mask64x2(a, self.splat_mask64x2(true)) - } - #[inline(always)] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { - let lanes = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i64x2(lanes); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask64x2( self, a: mask64x2, @@ -7811,94 +6901,12 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x8( - self, - values: f32x8, - mask: mask32x8, - merge: f32x8, - ) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x8(self, values: f32x8, mask: mask32x8) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x8( - self, - values: f32x8, - mask: mask32x8, - merge: f32x8, - ) -> f32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f32x8(self, a: f32x8, b: f32x8) -> mask32x8 { let (a0, a1) = self.split_f32x8(a); let (b0, b1) = self.split_f32x8(b); self.combine_mask32x4(self.simd_ne_f32x4(a0, b0), self.simd_ne_f32x4(a1, b1)) } #[inline(always)] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f32x8(self, a: f32x8, b: f32x8) -> f32x16 { f32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -7935,56 +6943,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x32(self, values: i8x32, mask: mask8x32) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x32( - self, - values: i8x32, - mask: mask8x32, - merge: i8x32, - ) -> i8x32 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i8x32(self, a: i8x32, b: i8x32) -> i8x64 { i8x64 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8342,20 +7300,6 @@ impl Simd for Sse4_2 { ) } #[inline(always)] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { - mask8x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { - i8x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -8367,36 +7311,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x64 { mask8x64 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8433,56 +7347,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x16(self, values: i16x16, mask: mask16x16) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x16( - self, - values: i16x16, - mask: mask16x16, - merge: i16x16, - ) -> i16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i16x16(self, a: i16x16, b: i16x16) -> i16x32 { i16x32 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8519,56 +7383,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x16(self, values: u16x16, mask: mask16x16) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x16( - self, - values: u16x16, - mask: mask16x16, - merge: u16x16, - ) -> u16x16 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u16x16(self, a: u16x16, b: u16x16) -> u16x32 { u16x32 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8602,20 +7416,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { - mask16x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { - i16x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -8627,36 +7427,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x32 { mask16x32 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8693,56 +7463,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x8( - self, - values: i32x8, - mask: mask32x8, - merge: i32x8, - ) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x8(self, values: i32x8, mask: mask32x8) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x8( - self, - values: i32x8, - mask: mask32x8, - merge: i32x8, - ) -> i32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i32x8(self, a: i32x8, b: i32x8) -> i32x16 { i32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8779,56 +7499,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x8( - self, - values: u32x8, - mask: mask32x8, - merge: u32x8, - ) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x8(self, values: u32x8, mask: mask32x8) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x8( - self, - values: u32x8, - mask: mask32x8, - merge: u32x8, - ) -> u32x8 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u32x8(self, a: u32x8, b: u32x8) -> u32x16 { u32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8849,20 +7519,6 @@ impl Simd for Sse4_2 { ) } #[inline(always)] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { - mask32x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { - i32x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -8874,36 +7530,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn combine_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x16 { mask32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -8940,94 +7566,12 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x4( - self, - values: f64x4, - mask: mask64x4, - merge: f64x4, - ) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x4(self, values: f64x4, mask: mask64x4) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x4( - self, - values: f64x4, - mask: mask64x4, - merge: f64x4, - ) -> f64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f64x4(self, a: f64x4, b: f64x4) -> mask64x4 { let (a0, a1) = self.split_f64x4(a); let (b0, b1) = self.split_f64x4(b); self.combine_mask64x2(self.simd_ne_f64x2(a0, b0), self.simd_ne_f64x2(a1, b1)) } #[inline(always)] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f64x4(self, a: f64x4, b: f64x4) -> f64x8 { f64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9064,56 +7608,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x4( - self, - values: i64x4, - mask: mask64x4, - merge: i64x4, - ) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x4(self, values: i64x4, mask: mask64x4) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x4( - self, - values: i64x4, - mask: mask64x4, - merge: i64x4, - ) -> i64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_i64x4(self, a: i64x4, b: i64x4) -> i64x8 { i64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9150,56 +7644,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x4( - self, - values: u64x4, - mask: mask64x4, - merge: u64x4, - ) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x4(self, values: u64x4, mask: mask64x4) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x32(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x4( - self, - values: u64x4, - mask: mask64x4, - merge: u64x4, - ) -> u64x4 { - let mask = mask8x32 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x32( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn combine_u64x4(self, a: u64x4, b: u64x4) -> u64x8 { u64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -9220,59 +7664,15 @@ impl Simd for Sse4_2 { ) } #[inline(always)] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { - mask64x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { - i64x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> () { assert!( index < 4usize, "mask lane index {index} is out of bounds for {} lanes", 4usize - ); - let mut lanes: [i64; 4usize] = (*a).into(); - lanes[index] = if value { !0 } else { 0 }; - *a = lanes.simd_into(self); - } - #[inline(always)] - fn rotate_elements_left_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } + ); + let mut lanes: [i64; 4usize] = (*a).into(); + lanes[index] = if value { !0 } else { 0 }; + *a = lanes.simd_into(self); } #[inline(always)] fn combine_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x8 { @@ -9311,94 +7711,12 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f32x16( - self, - values: f32x16, - mask: mask32x16, - merge: f32x16, - ) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f32x16(self, values: f32x16, mask: mask32x16) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f32x16( - self, - values: f32x16, - mask: mask32x16, - merge: f32x16, - ) -> f32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f32x16(self, a: f32x16, b: f32x16) -> mask32x16 { let (a0, a1) = self.split_f32x16(a); let (b0, b1) = self.split_f32x16(b); self.combine_mask32x8(self.simd_ne_f32x8(a0, b0), self.simd_ne_f32x8(a1, b1)) } #[inline(always)] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f32x16(self, a: f32x16) -> (f32x8, f32x8) { ( f32x8 { @@ -9428,56 +7746,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i8x64(self, values: i8x64, mask: mask8x64) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i8x64( - self, - values: i8x64, - mask: mask8x64, - merge: i8x64, - ) -> i8x64 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i8x64(self, a: i8x64) -> (i8x32, i8x32) { ( i8x32 { @@ -10036,20 +8304,6 @@ impl Simd for Sse4_2 { kernel(self, bits) } #[inline(always)] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { - mask8x64 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { - i8x64 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> () { assert!( index < 64usize, @@ -10061,36 +8315,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask8x64(self, a: mask8x64) -> (mask8x32, mask8x32) { ( mask8x32 { @@ -10120,56 +8344,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i16x32(self, values: i16x32, mask: mask16x32) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i16x32( - self, - values: i16x32, - mask: mask16x32, - merge: i16x32, - ) -> i16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i16x32(self, a: i16x32) -> (i16x16, i16x16) { ( i16x16 { @@ -10199,56 +8373,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u16x32(self, values: u16x32, mask: mask16x32) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u16x32( - self, - values: u16x32, - mask: mask16x32, - merge: u16x32, - ) -> u16x32 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u16x32(self, a: u16x32) -> (u16x16, u16x16) { ( u16x16 { @@ -10278,20 +8402,6 @@ impl Simd for Sse4_2 { kernel(self, a) } #[inline(always)] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { - mask16x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { - i16x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -10303,36 +8413,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask16x32(self, a: mask16x32) -> (mask16x16, mask16x16) { ( mask16x16 { @@ -10362,56 +8442,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i32x16( - self, - values: i32x16, - mask: mask32x16, - merge: i32x16, - ) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i32x16(self, values: i32x16, mask: mask32x16) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i32x16( - self, - values: i32x16, - mask: mask32x16, - merge: i32x16, - ) -> i32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i32x16(self, a: i32x16) -> (i32x8, i32x8) { ( i32x8 { @@ -10441,56 +8471,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u32x16( - self, - values: u32x16, - mask: mask32x16, - merge: u32x16, - ) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u32x16(self, values: u32x16, mask: mask32x16) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u32x16( - self, - values: u32x16, - mask: mask32x16, - merge: u32x16, - ) -> u32x16 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u32x16(self, a: u32x16) -> (u32x8, u32x8) { ( u32x8 { @@ -10504,20 +8484,6 @@ impl Simd for Sse4_2 { ) } #[inline(always)] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { - mask32x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { - i32x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -10529,36 +8495,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask32x16(self, a: mask32x16) -> (mask32x8, mask32x8) { ( mask32x8 { @@ -10588,94 +8524,12 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_f64x8( - self, - values: f64x8, - mask: mask64x8, - merge: f64x8, - ) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_f64x8(self, values: f64x8, mask: mask64x8) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_f64x8( - self, - values: f64x8, - mask: mask64x8, - merge: f64x8, - ) -> f64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn simd_ne_f64x8(self, a: f64x8, b: f64x8) -> mask64x8 { let (a0, a1) = self.split_f64x8(a); let (b0, b1) = self.split_f64x8(b); self.combine_mask64x4(self.simd_ne_f64x4(a0, b0), self.simd_ne_f64x4(a1, b1)) } #[inline(always)] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f64x8(self, a: f64x8) -> (f64x4, f64x4) { ( f64x4 { @@ -10705,56 +8559,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_i64x8( - self, - values: i64x8, - mask: mask64x8, - merge: i64x8, - ) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_i64x8(self, values: i64x8, mask: mask64x8) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_i64x8( - self, - values: i64x8, - mask: mask64x8, - merge: i64x8, - ) -> i64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_i64x8(self, a: i64x8) -> (i64x4, i64x4) { ( i64x4 { @@ -10784,56 +8588,6 @@ impl Simd for Sse4_2 { }) } #[inline(always)] - fn compress_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn compress_merge_u64x8( - self, - values: u64x8, - mask: mask64x8, - merge: u64x8, - ) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.compress_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] - fn expand_u64x8(self, values: u64x8, mask: mask64x8) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_u8x64(Bytes::to_bytes(values), mask)) - } - #[inline(always)] - fn expand_merge_u64x8( - self, - values: u64x8, - mask: mask64x8, - merge: u64x8, - ) -> u64x8 { - let mask = mask8x64 { - val: crate::transmute::checked_transmute_copy(&mask.val), - simd: self, - }; - Bytes::from_bytes(self.expand_merge_u8x64( - Bytes::to_bytes(values), - mask, - Bytes::to_bytes(merge), - )) - } - #[inline(always)] fn split_u64x8(self, a: u64x8) -> (u64x4, u64x4) { ( u64x4 { @@ -10847,20 +8601,6 @@ impl Simd for Sse4_2 { ) } #[inline(always)] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { - mask64x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { - i64x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -10872,36 +8612,6 @@ impl Simd for Sse4_2 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn split_mask64x8(self, a: mask64x8) -> (mask64x4, mask64x4) { ( mask64x4 { diff --git a/fearless_simd/src/generated/wasm.rs b/fearless_simd/src/generated/wasm.rs index e843e416..6723ea9a 100644 --- a/fearless_simd/src/generated/wasm.rs +++ b/fearless_simd/src/generated/wasm.rs @@ -342,14 +342,6 @@ impl Simd for WasmSimd128 { u32x4_shuffle::<1, 3, 5, 7>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { - (self.zip_low_f32x4(a, b), self.zip_high_f32x4(a, b)) - } - #[inline(always)] - fn deinterleave_f32x4(self, a: f32x4, b: f32x4) -> (f32x4, f32x4) { - (self.unzip_low_f32x4(a, b), self.unzip_high_f32x4(a, b)) - } - #[inline(always)] fn mul_add_f32x4(self, a: f32x4, b: f32x4, c: f32x4) -> f32x4 { #[cfg(target_feature = "relaxed-simd")] { @@ -413,38 +405,6 @@ impl Simd for WasmSimd128 { a * const { f32::to_radians(1.0) } } #[inline(always)] - fn is_nan_f32x4(self, a: f32x4) -> mask32x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x4(self, a: f32x4) -> mask32x4 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x4(self, a: f32x4) -> mask32x4 { - let i: i32x4 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x4(self, a: f32x4) -> mask32x4 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f32x4(self, a: mask32x4, b: f32x4, c: f32x4) -> f32x4 { #[cfg(target_feature = "relaxed-simd")] { @@ -630,14 +590,6 @@ impl Simd for WasmSimd128 { i8x16_popcnt(a.into()).simd_into(self) } #[inline(always)] - fn count_zeros_i8x16(self, a: i8x16) -> i8x16 { - self.count_ones_i8x16(self.not_i8x16(a)) - } - #[inline(always)] - fn swap_bytes_i8x16(self, a: i8x16) -> i8x16 { - a - } - #[inline(always)] fn reverse_bits_i8x16(self, a: i8x16) -> i8x16 { let value = a.into(); let nibble_mask = u8x16_splat(0x0f); @@ -676,18 +628,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn and_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_i8x16(self, a: i8x16, b: i8x16) -> i8x16 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_i8x16(self, a: i8x16) -> i8x16 { v128_not(a.into()).simd_into(self) } @@ -839,14 +779,6 @@ impl Simd for WasmSimd128 { i8x16_min(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn clamp_i8x16(self, a: i8x16, b: i8x16, c: i8x16) -> i8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i8x16(self, a: i8x16, b: i8x16) -> mask8x16 { i8x16_eq(a.into(), b.into()).simd_into(self) } @@ -892,14 +824,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn interleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { - (self.zip_low_i8x16(a, b), self.zip_high_i8x16(a, b)) - } - #[inline(always)] - fn deinterleave_i8x16(self, a: i8x16, b: i8x16) -> (i8x16, i8x16) { - (self.unzip_low_i8x16(a, b), self.unzip_high_i8x16(a, b)) - } - #[inline(always)] fn select_i8x16(self, a: mask8x16, b: i8x16, c: i8x16) -> i8x16 { #[cfg(target_feature = "relaxed-simd")] { @@ -1003,28 +927,10 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn widening_mul_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.mul_i16x8(a0, b0), self.mul_i16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_i8x16(self, a: i8x16, b: i8x16) -> (i16x8, i16x8) { - let (a0, a1) = self.widen_i8x16(a); - let (b0, b1) = self.widen_i8x16(b); - (self.add_i16x8(a0, b0), self.add_i16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i8x16(self, a: i8x16) -> i16x8 { i16x8_extadd_pairwise_i8x16(a.into()).simd_into(self) } #[inline(always)] - fn pairwise_dot_product_i8x16(self, a: i8x16, b: i8x16) -> i16x8 { - let (low, high) = self.widening_mul_i8x16(a, b); - let (even, odd) = self.deinterleave_i16x8(low, high); - self.add_i16x8(even, odd) - } - #[inline(always)] fn splat_u8x16(self, val: u8) -> u8x16 { u8x16_splat(val).simd_into(self) } @@ -1198,14 +1104,6 @@ impl Simd for WasmSimd128 { i8x16_popcnt(a.into()).simd_into(self) } #[inline(always)] - fn count_zeros_u8x16(self, a: u8x16) -> u8x16 { - self.count_ones_u8x16(self.not_u8x16(a)) - } - #[inline(always)] - fn swap_bytes_u8x16(self, a: u8x16) -> u8x16 { - a - } - #[inline(always)] fn reverse_bits_u8x16(self, a: u8x16) -> u8x16 { let value = a.into(); let nibble_mask = u8x16_splat(0x0f); @@ -1407,14 +1305,6 @@ impl Simd for WasmSimd128 { u8x16_min(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn clamp_u8x16(self, a: u8x16, b: u8x16, c: u8x16) -> u8x16 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u8x16(self, a: u8x16, b: u8x16) -> mask8x16 { u8x16_eq(a.into(), b.into()).simd_into(self) } @@ -1460,14 +1350,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn interleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { - (self.zip_low_u8x16(a, b), self.zip_high_u8x16(a, b)) - } - #[inline(always)] - fn deinterleave_u8x16(self, a: u8x16, b: u8x16) -> (u8x16, u8x16) { - (self.unzip_low_u8x16(a, b), self.unzip_high_u8x16(a, b)) - } - #[inline(always)] fn select_u8x16(self, a: mask8x16, b: u8x16, c: u8x16) -> u8x16 { #[cfg(target_feature = "relaxed-simd")] { @@ -1567,28 +1449,10 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn widening_mul_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.mul_u16x8(a0, b0), self.mul_u16x8(a1, b1)) - } - #[inline(always)] - fn widening_add_u8x16(self, a: u8x16, b: u8x16) -> (u16x8, u16x8) { - let (a0, a1) = self.widen_u8x16(a); - let (b0, b1) = self.widen_u8x16(b); - (self.add_u16x8(a0, b0), self.add_u16x8(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u8x16(self, a: u8x16) -> u16x8 { u16x8_extadd_pairwise_u8x16(a.into()).simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u8x16(self, a: u8x16, b: u8x16) -> u16x8 { - let (low, high) = self.widening_mul_u8x16(a, b); - let (even, odd) = self.deinterleave_u16x8(low, high); - self.add_u16x8(even, odd) - } - #[inline(always)] fn splat_mask8x16(self, val: bool) -> mask8x16 { let val: i8 = if val { !0 } else { 0 }; i8x16_splat(val).simd_into(self) @@ -1607,20 +1471,6 @@ impl Simd for WasmSimd128 { i8x16_bitmask(a.into()) as u64 } #[inline(always)] - fn from_vector_mask8x16(self, vector: i8x16) -> mask8x16 { - mask8x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x16(self, a: mask8x16) -> i8x16 { - i8x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x16(self, a: &mut mask8x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -1632,64 +1482,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x16( - self, - a: mask8x16, - ) -> mask8x16 { - let int = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_mask8x16(self, a: mask8x16, b: mask8x16) -> mask8x16 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn not_mask8x16(self, a: mask8x16) -> mask8x16 { - v128_not(a.into()).simd_into(self) - } - #[inline(always)] - fn reverse_mask8x16(self, a: mask8x16) -> mask8x16 { - let lanes = i8x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i8x16(lanes); - mask8x16 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask8x16( self, a: mask8x16, @@ -1814,10 +1606,6 @@ impl Simd for WasmSimd128 { u16x8_extadd_pairwise_u8x16(i8x16_popcnt(a.into())).simd_into(self) } #[inline(always)] - fn count_zeros_i16x8(self, a: i16x8) -> i16x8 { - self.count_ones_i16x8(self.not_i16x8(a)) - } - #[inline(always)] fn swap_bytes_i16x8(self, a: i16x8) -> i16x8 { u8x16_shuffle::<1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14>(a.into(), a.into()) .simd_into(self) @@ -1858,18 +1646,6 @@ impl Simd for WasmSimd128 { i16x8_mul(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn and_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_i16x8(self, a: i16x8, b: i16x8) -> i16x8 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_i16x8(self, a: i16x8) -> i16x8 { v128_not(a.into()).simd_into(self) } @@ -1961,14 +1737,6 @@ impl Simd for WasmSimd128 { i16x8_min(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn clamp_i16x8(self, a: i16x8, b: i16x8, c: i16x8) -> i16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i16x8(self, a: i16x8, b: i16x8) -> mask16x8 { i16x8_eq(a.into(), b.into()).simd_into(self) } @@ -2001,14 +1769,6 @@ impl Simd for WasmSimd128 { u16x8_shuffle::<1, 3, 5, 7, 9, 11, 13, 15>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { - (self.zip_low_i16x8(a, b), self.zip_high_i16x8(a, b)) - } - #[inline(always)] - fn deinterleave_i16x8(self, a: i16x8, b: i16x8) -> (i16x8, i16x8) { - (self.unzip_low_i16x8(a, b), self.unzip_high_i16x8(a, b)) - } - #[inline(always)] fn select_i16x8(self, a: mask16x8, b: i16x8, c: i16x8) -> i16x8 { #[cfg(target_feature = "relaxed-simd")] { @@ -2088,18 +1848,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn widening_mul_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.mul_i32x4(a0, b0), self.mul_i32x4(a1, b1)) - } - #[inline(always)] - fn widening_add_i16x8(self, a: i16x8, b: i16x8) -> (i32x4, i32x4) { - let (a0, a1) = self.widen_i16x8(a); - let (b0, b1) = self.widen_i16x8(b); - (self.add_i32x4(a0, b0), self.add_i32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i16x8(self, a: i16x8) -> i32x4 { i32x4_extadd_pairwise_i16x8(a.into()).simd_into(self) } @@ -2194,10 +1942,6 @@ impl Simd for WasmSimd128 { u16x8_extadd_pairwise_u8x16(i8x16_popcnt(a.into())).simd_into(self) } #[inline(always)] - fn count_zeros_u16x8(self, a: u16x8) -> u16x8 { - self.count_ones_u16x8(self.not_u16x8(a)) - } - #[inline(always)] fn swap_bytes_u16x8(self, a: u16x8) -> u16x8 { u8x16_shuffle::<1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14>(a.into(), a.into()) .simd_into(self) @@ -2238,18 +1982,6 @@ impl Simd for WasmSimd128 { u16x8_mul(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn and_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_u16x8(self, a: u16x8, b: u16x8) -> u16x8 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_u16x8(self, a: u16x8) -> u16x8 { v128_not(a.into()).simd_into(self) } @@ -2341,14 +2073,6 @@ impl Simd for WasmSimd128 { u16x8_min(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn clamp_u16x8(self, a: u16x8, b: u16x8, c: u16x8) -> u16x8 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u16x8(self, a: u16x8, b: u16x8) -> mask16x8 { u16x8_eq(a.into(), b.into()).simd_into(self) } @@ -2381,14 +2105,6 @@ impl Simd for WasmSimd128 { u16x8_shuffle::<1, 3, 5, 7, 9, 11, 13, 15>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { - (self.zip_low_u16x8(a, b), self.zip_high_u16x8(a, b)) - } - #[inline(always)] - fn deinterleave_u16x8(self, a: u16x8, b: u16x8) -> (u16x8, u16x8) { - (self.unzip_low_u16x8(a, b), self.unzip_high_u16x8(a, b)) - } - #[inline(always)] fn select_u16x8(self, a: mask16x8, b: u16x8, c: u16x8) -> u16x8 { #[cfg(target_feature = "relaxed-simd")] { @@ -2464,28 +2180,10 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn widening_mul_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.mul_u32x4(a0, b0), self.mul_u32x4(a1, b1)) - } - #[inline(always)] - fn widening_add_u16x8(self, a: u16x8, b: u16x8) -> (u32x4, u32x4) { - let (a0, a1) = self.widen_u16x8(a); - let (b0, b1) = self.widen_u16x8(b); - (self.add_u32x4(a0, b0), self.add_u32x4(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u16x8(self, a: u16x8) -> u32x4 { u32x4_extadd_pairwise_u16x8(a.into()).simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u16x8(self, a: u16x8, b: u16x8) -> u32x4 { - let (low, high) = self.widening_mul_u16x8(a, b); - let (even, odd) = self.deinterleave_u32x4(low, high); - self.add_u32x4(even, odd) - } - #[inline(always)] fn narrow_u16x8(self, a: u16x8, b: u16x8) -> u8x16 { let mask = u16x8_splat(255); u8x16_narrow_i16x8(v128_and(a.into(), mask), v128_and(b.into(), mask)).simd_into(self) @@ -2523,20 +2221,6 @@ impl Simd for WasmSimd128 { i16x8_bitmask(a.into()) as u64 } #[inline(always)] - fn from_vector_mask16x8(self, vector: i16x8) -> mask16x8 { - mask16x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x8(self, a: mask16x8) -> i16x8 { - i16x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x8(self, a: &mut mask16x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -2548,64 +2232,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x8( - self, - a: mask16x8, - ) -> mask16x8 { - let int = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_mask16x8(self, a: mask16x8, b: mask16x8) -> mask16x8 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn not_mask16x8(self, a: mask16x8) -> mask16x8 { - v128_not(a.into()).simd_into(self) - } - #[inline(always)] - fn reverse_mask16x8(self, a: mask16x8) -> mask16x8 { - let lanes = i16x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i16x8(lanes); - mask16x8 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask16x8( self, a: mask16x8, @@ -2735,10 +2361,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn count_zeros_i32x4(self, a: i32x4) -> i32x4 { - self.count_ones_i32x4(self.not_i32x4(a)) - } - #[inline(always)] fn swap_bytes_i32x4(self, a: i32x4) -> i32x4 { u8x16_shuffle::<3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12>(a.into(), a.into()) .simd_into(self) @@ -2789,18 +2411,6 @@ impl Simd for WasmSimd128 { i32x4_mul(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn and_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_i32x4(self, a: i32x4, b: i32x4) -> i32x4 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_i32x4(self, a: i32x4) -> i32x4 { v128_not(a.into()).simd_into(self) } @@ -2872,14 +2482,6 @@ impl Simd for WasmSimd128 { i32x4_min(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn clamp_i32x4(self, a: i32x4, b: i32x4, c: i32x4) -> i32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i32x4(self, a: i32x4, b: i32x4) -> mask32x4 { i32x4_eq(a.into(), b.into()).simd_into(self) } @@ -2912,14 +2514,6 @@ impl Simd for WasmSimd128 { u32x4_shuffle::<1, 3, 5, 7>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { - (self.zip_low_i32x4(a, b), self.zip_high_i32x4(a, b)) - } - #[inline(always)] - fn deinterleave_i32x4(self, a: i32x4, b: i32x4) -> (i32x4, i32x4) { - (self.unzip_low_i32x4(a, b), self.unzip_high_i32x4(a, b)) - } - #[inline(always)] fn select_i32x4(self, a: mask32x4, b: i32x4, c: i32x4) -> i32x4 { #[cfg(target_feature = "relaxed-simd")] { @@ -2999,18 +2593,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn widening_mul_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.mul_i64x2(a0, b0), self.mul_i64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_i32x4(self, a: i32x4, b: i32x4) -> (i64x2, i64x2) { - let (a0, a1) = self.widen_i32x4(a); - let (b0, b1) = self.widen_i32x4(b); - (self.add_i64x2(a0, b0), self.add_i64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_i32x4(self, a: i32x4) -> i64x2 { i64x2_add( i64x2_shr(i64x2_shl(a.into(), 32), 32), @@ -3019,12 +2601,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_i32x4(self, a: i32x4, b: i32x4) -> i64x2 { - let (low, high) = self.widening_mul_i32x4(a, b); - let (even, odd) = self.deinterleave_i64x2(low, high); - self.add_i64x2(even, odd) - } - #[inline(always)] fn narrow_i32x4(self, a: i32x4, b: i32x4) -> i16x8 { let mask = i32x4_splat(65535); u16x8_narrow_i32x4(v128_and(a.into(), mask), v128_and(b.into(), mask)).simd_into(self) @@ -3116,10 +2692,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn count_zeros_u32x4(self, a: u32x4) -> u32x4 { - self.count_ones_u32x4(self.not_u32x4(a)) - } - #[inline(always)] fn swap_bytes_u32x4(self, a: u32x4) -> u32x4 { u8x16_shuffle::<3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12>(a.into(), a.into()) .simd_into(self) @@ -3164,18 +2736,6 @@ impl Simd for WasmSimd128 { u32x4_mul(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn and_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_u32x4(self, a: u32x4, b: u32x4) -> u32x4 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_u32x4(self, a: u32x4) -> u32x4 { v128_not(a.into()).simd_into(self) } @@ -3247,14 +2807,6 @@ impl Simd for WasmSimd128 { u32x4_min(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn clamp_u32x4(self, a: u32x4, b: u32x4, c: u32x4) -> u32x4 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u32x4(self, a: u32x4, b: u32x4) -> mask32x4 { u32x4_eq(a.into(), b.into()).simd_into(self) } @@ -3287,14 +2839,6 @@ impl Simd for WasmSimd128 { u32x4_shuffle::<1, 3, 5, 7>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { - (self.zip_low_u32x4(a, b), self.zip_high_u32x4(a, b)) - } - #[inline(always)] - fn deinterleave_u32x4(self, a: u32x4, b: u32x4) -> (u32x4, u32x4) { - (self.unzip_low_u32x4(a, b), self.unzip_high_u32x4(a, b)) - } - #[inline(always)] fn select_u32x4(self, a: mask32x4, b: u32x4, c: u32x4) -> u32x4 { #[cfg(target_feature = "relaxed-simd")] { @@ -3370,18 +2914,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn widening_mul_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.mul_u64x2(a0, b0), self.mul_u64x2(a1, b1)) - } - #[inline(always)] - fn widening_add_u32x4(self, a: u32x4, b: u32x4) -> (u64x2, u64x2) { - let (a0, a1) = self.widen_u32x4(a); - let (b0, b1) = self.widen_u32x4(b); - (self.add_u64x2(a0, b0), self.add_u64x2(a1, b1)) - } - #[inline(always)] fn pairwise_widening_add_u32x4(self, a: u32x4) -> u64x2 { u64x2_add( v128_and(a.into(), u64x2_splat(0xffff_ffff)), @@ -3390,12 +2922,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn pairwise_dot_product_u32x4(self, a: u32x4, b: u32x4) -> u64x2 { - let (low, high) = self.widening_mul_u32x4(a, b); - let (even, odd) = self.deinterleave_u64x2(low, high); - self.add_u64x2(even, odd) - } - #[inline(always)] fn narrow_u32x4(self, a: u32x4, b: u32x4) -> u16x8 { let mask = u32x4_splat(65535); u16x8_narrow_i32x4(v128_and(a.into(), mask), v128_and(b.into(), mask)).simd_into(self) @@ -3437,20 +2963,6 @@ impl Simd for WasmSimd128 { i32x4_bitmask(a.into()) as u64 } #[inline(always)] - fn from_vector_mask32x4(self, vector: i32x4) -> mask32x4 { - mask32x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x4(self, a: mask32x4) -> i32x4 { - i32x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x4(self, a: &mut mask32x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -3462,64 +2974,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x4( - self, - a: mask32x4, - ) -> mask32x4 { - let int = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_mask32x4(self, a: mask32x4, b: mask32x4) -> mask32x4 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn not_mask32x4(self, a: mask32x4) -> mask32x4 { - v128_not(a.into()).simd_into(self) - } - #[inline(always)] - fn reverse_mask32x4(self, a: mask32x4) -> mask32x4 { - let lanes = i32x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i32x4(lanes); - mask32x4 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask32x4( self, a: mask32x4, @@ -3792,14 +3246,6 @@ impl Simd for WasmSimd128 { u64x2_shuffle::<1, 3>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { - (self.zip_low_f64x2(a, b), self.zip_high_f64x2(a, b)) - } - #[inline(always)] - fn deinterleave_f64x2(self, a: f64x2, b: f64x2) -> (f64x2, f64x2) { - (self.unzip_low_f64x2(a, b), self.unzip_high_f64x2(a, b)) - } - #[inline(always)] fn mul_add_f64x2(self, a: f64x2, b: f64x2, c: f64x2) -> f64x2 { #[cfg(target_feature = "relaxed-simd")] { @@ -3863,38 +3309,6 @@ impl Simd for WasmSimd128 { a * const { f64::to_radians(1.0) } } #[inline(always)] - fn is_nan_f64x2(self, a: f64x2) -> mask64x2 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x2(self, a: f64x2) -> mask64x2 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x2(self, a: f64x2) -> mask64x2 { - let i: i64x2 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x2(self, a: f64x2) -> mask64x2 { - !a.is_sign_positive() - } - #[inline(always)] fn select_f64x2(self, a: mask64x2, b: f64x2, c: f64x2) -> f64x2 { #[cfg(target_feature = "relaxed-simd")] { @@ -4062,10 +3476,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn count_zeros_i64x2(self, a: i64x2) -> i64x2 { - self.count_ones_i64x2(self.not_i64x2(a)) - } - #[inline(always)] fn swap_bytes_i64x2(self, a: i64x2) -> i64x2 { u8x16_shuffle::<7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8>(a.into(), a.into()) .simd_into(self) @@ -4116,18 +3526,6 @@ impl Simd for WasmSimd128 { i64x2_mul(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn and_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_i64x2(self, a: i64x2, b: i64x2) -> i64x2 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_i64x2(self, a: i64x2) -> i64x2 { v128_not(a.into()).simd_into(self) } @@ -4193,14 +3591,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn clamp_i64x2(self, a: i64x2, b: i64x2, c: i64x2) -> i64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_i64x2(self, a: i64x2, b: i64x2) -> mask64x2 { i64x2_eq(a.into(), b.into()).simd_into(self) } @@ -4233,14 +3623,6 @@ impl Simd for WasmSimd128 { u64x2_shuffle::<1, 3>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { - (self.zip_low_i64x2(a, b), self.zip_high_i64x2(a, b)) - } - #[inline(always)] - fn deinterleave_i64x2(self, a: i64x2, b: i64x2) -> (i64x2, i64x2) { - (self.unzip_low_i64x2(a, b), self.unzip_high_i64x2(a, b)) - } - #[inline(always)] fn select_i64x2(self, a: mask64x2, b: i64x2, c: i64x2) -> i64x2 { #[cfg(target_feature = "relaxed-simd")] { @@ -4411,10 +3793,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn count_zeros_u64x2(self, a: u64x2) -> u64x2 { - self.count_ones_u64x2(self.not_u64x2(a)) - } - #[inline(always)] fn swap_bytes_u64x2(self, a: u64x2) -> u64x2 { u8x16_shuffle::<7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8>(a.into(), a.into()) .simd_into(self) @@ -4465,18 +3843,6 @@ impl Simd for WasmSimd128 { u64x2_mul(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn and_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_u64x2(self, a: u64x2, b: u64x2) -> u64x2 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] fn not_u64x2(self, a: u64x2) -> u64x2 { v128_not(a.into()).simd_into(self) } @@ -4542,14 +3908,6 @@ impl Simd for WasmSimd128 { .simd_into(self) } #[inline(always)] - fn clamp_u64x2(self, a: u64x2, b: u64x2, c: u64x2) -> u64x2 { - debug_assert!( - b.simd_le(c).all_true(), - "clamp requires min <= max for all elements" - ); - a.max(b).min(c) - } - #[inline(always)] fn simd_eq_u64x2(self, a: u64x2, b: u64x2) -> mask64x2 { [ -(u64::eq(&a[0usize], &b[0usize]) as i64), @@ -4594,14 +3952,6 @@ impl Simd for WasmSimd128 { u64x2_shuffle::<1, 3>(a.into(), b.into()).simd_into(self) } #[inline(always)] - fn interleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { - (self.zip_low_u64x2(a, b), self.zip_high_u64x2(a, b)) - } - #[inline(always)] - fn deinterleave_u64x2(self, a: u64x2, b: u64x2) -> (u64x2, u64x2) { - (self.unzip_low_u64x2(a, b), self.unzip_high_u64x2(a, b)) - } - #[inline(always)] fn select_u64x2(self, a: mask64x2, b: u64x2, c: u64x2) -> u64x2 { #[cfg(target_feature = "relaxed-simd")] { @@ -4711,20 +4061,6 @@ impl Simd for WasmSimd128 { i64x2_bitmask(a.into()) as u64 } #[inline(always)] - fn from_vector_mask64x2(self, vector: i64x2) -> mask64x2 { - mask64x2 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x2(self, a: mask64x2) -> i64x2 { - i64x2 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x2(self, a: &mut mask64x2, index: usize, value: bool) -> () { assert!( index < 2usize, @@ -4736,64 +4072,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x2( - self, - a: mask64x2, - ) -> mask64x2 { - let int = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn and_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - v128_and(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn or_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - v128_or(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn xor_mask64x2(self, a: mask64x2, b: mask64x2) -> mask64x2 { - v128_xor(a.into(), b.into()).simd_into(self) - } - #[inline(always)] - fn not_mask64x2(self, a: mask64x2) -> mask64x2 { - v128_not(a.into()).simd_into(self) - } - #[inline(always)] - fn reverse_mask64x2(self, a: mask64x2) -> mask64x2 { - let lanes = i64x2 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let reversed = self.reverse_i64x2(lanes); - mask64x2 { - val: crate::transmute::checked_transmute_copy(&reversed.val), - simd: self, - } - } - #[inline(always)] fn select_mask64x2( self, a: mask64x2, @@ -4920,38 +4198,6 @@ impl Simd for WasmSimd128 { self.combine_mask32x4(self.simd_ne_f32x4(a0, b0), self.simd_ne_f32x4(a1, b1)) } #[inline(always)] - fn is_nan_f32x8(self, a: f32x8) -> mask32x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x8(self, a: f32x8) -> mask32x8 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x8(self, a: f32x8) -> mask32x8 { - let i: i32x8 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x8(self, a: f32x8) -> mask32x8 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f32x8(self, a: f32x8, b: f32x8) -> f32x16 { f32x16 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -5297,20 +4543,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask8x32(self, vector: i8x32) -> mask8x32 { - mask8x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x32(self, a: mask8x32) -> i8x32 { - i8x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x32(self, a: &mut mask8x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -5322,36 +4554,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x32( - self, - a: mask8x32, - ) -> mask8x32 { - let int = i8x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask8x32(self, a: mask8x32, b: mask8x32) -> mask8x32 { let (a0, a1) = self.split_mask8x32(a); let (b0, b1) = self.split_mask8x32(b); @@ -5560,20 +4762,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask16x16(self, vector: i16x16) -> mask16x16 { - mask16x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x16(self, a: mask16x16) -> i16x16 { - i16x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x16(self, a: &mut mask16x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -5585,36 +4773,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x16( - self, - a: mask16x16, - ) -> mask16x16 { - let int = i16x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask16x16(self, a: mask16x16, b: mask16x16) -> mask16x16 { let (a0, a1) = self.split_mask16x16(a); let (b0, b1) = self.split_mask16x16(b); @@ -5823,20 +4981,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask32x8(self, vector: i32x8) -> mask32x8 { - mask32x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x8(self, a: mask32x8) -> i32x8 { - i32x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x8(self, a: &mut mask32x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -5848,36 +4992,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x8( - self, - a: mask32x8, - ) -> mask32x8 { - let int = i32x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask32x8(self, a: mask32x8, b: mask32x8) -> mask32x8 { let (a0, a1) = self.split_mask32x8(a); let (b0, b1) = self.split_mask32x8(b); @@ -5975,38 +5089,6 @@ impl Simd for WasmSimd128 { self.combine_mask64x2(self.simd_ne_f64x2(a0, b0), self.simd_ne_f64x2(a1, b1)) } #[inline(always)] - fn is_nan_f64x4(self, a: f64x4) -> mask64x4 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x4(self, a: f64x4) -> mask64x4 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x4(self, a: f64x4) -> mask64x4 { - let i: i64x4 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x4(self, a: f64x4) -> mask64x4 { - !a.is_sign_positive() - } - #[inline(always)] fn combine_f64x4(self, a: f64x4, b: f64x4) -> f64x8 { f64x8 { val: crate::support::Aligned512([a.val.0[0], a.val.0[1], b.val.0[0], b.val.0[1]]), @@ -6209,20 +5291,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask64x4(self, vector: i64x4) -> mask64x4 { - mask64x4 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x4(self, a: mask64x4) -> i64x4 { - i64x4 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x4(self, a: &mut mask64x4, index: usize, value: bool) -> () { assert!( index < 4usize, @@ -6234,36 +5302,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x4( - self, - a: mask64x4, - ) -> mask64x4 { - let int = i64x4 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x4 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask64x4(self, a: mask64x4, b: mask64x4) -> mask64x4 { let (a0, a1) = self.split_mask64x4(a); let (b0, b1) = self.split_mask64x4(b); @@ -6361,38 +5399,6 @@ impl Simd for WasmSimd128 { self.combine_mask32x8(self.simd_ne_f32x8(a0, b0), self.simd_ne_f32x8(a1, b1)) } #[inline(always)] - fn is_nan_f32x16(self, a: f32x16) -> mask32x16 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_eq(f32::INFINITY) - } - #[inline(always)] - fn is_finite_f32x16(self, a: f32x16) -> mask32x16 { - a.abs().simd_lt(f32::INFINITY) - } - #[inline(always)] - fn is_subnormal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & 0x7F80_0000_i32).simd_eq(0) & (i & 0x007F_FFFF_i32).simd_ne(0) - } - #[inline(always)] - fn is_normal_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - let exp = i & 0x7F80_0000_i32; - exp.simd_ne(0) & exp.simd_ne(0x7F80_0000_i32) - } - #[inline(always)] - fn is_sign_positive_f32x16(self, a: f32x16) -> mask32x16 { - let i: i32x16 = a.bitcast(); - (i & i32::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f32x16(self, a: f32x16) -> mask32x16 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f32x16(self, a: f32x16) -> (f32x8, f32x8) { ( f32x8 { @@ -6690,20 +5696,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask8x64(self, vector: i8x64) -> mask8x64 { - mask8x64 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask8x64(self, a: mask8x64) -> i8x64 { - i8x64 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask8x64(self, a: &mut mask8x64, index: usize, value: bool) -> () { assert!( index < 64usize, @@ -6715,36 +5707,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask8x64( - self, - a: mask8x64, - ) -> mask8x64 { - let int = i8x64 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask8x64 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask8x64(self, a: mask8x64, b: mask8x64) -> mask8x64 { let (a0, a1) = self.split_mask8x64(a); let (b0, b1) = self.split_mask8x64(b); @@ -6932,20 +5894,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask16x32(self, vector: i16x32) -> mask16x32 { - mask16x32 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask16x32(self, a: mask16x32) -> i16x32 { - i16x32 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask16x32(self, a: &mut mask16x32, index: usize, value: bool) -> () { assert!( index < 32usize, @@ -6957,36 +5905,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask16x32( - self, - a: mask16x32, - ) -> mask16x32 { - let int = i16x32 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask16x32 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask16x32(self, a: mask16x32, b: mask16x32) -> mask16x32 { let (a0, a1) = self.split_mask16x32(a); let (b0, b1) = self.split_mask16x32(b); @@ -7177,20 +6095,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask32x16(self, vector: i32x16) -> mask32x16 { - mask32x16 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask32x16(self, a: mask32x16) -> i32x16 { - i32x16 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask32x16(self, a: &mut mask32x16, index: usize, value: bool) -> () { assert!( index < 16usize, @@ -7202,36 +6106,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask32x16( - self, - a: mask32x16, - ) -> mask32x16 { - let int = i32x16 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask32x16 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask32x16(self, a: mask32x16, b: mask32x16) -> mask32x16 { let (a0, a1) = self.split_mask32x16(a); let (b0, b1) = self.split_mask32x16(b); @@ -7322,38 +6196,6 @@ impl Simd for WasmSimd128 { self.combine_mask64x4(self.simd_ne_f64x4(a0, b0), self.simd_ne_f64x4(a1, b1)) } #[inline(always)] - fn is_nan_f64x8(self, a: f64x8) -> mask64x8 { - a.simd_ne(a) - } - #[inline(always)] - fn is_infinite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_eq(f64::INFINITY) - } - #[inline(always)] - fn is_finite_f64x8(self, a: f64x8) -> mask64x8 { - a.abs().simd_lt(f64::INFINITY) - } - #[inline(always)] - fn is_subnormal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & 0x7FF0_0000_0000_0000_i64).simd_eq(0) & (i & 0x000F_FFFF_FFFF_FFFF_i64).simd_ne(0) - } - #[inline(always)] - fn is_normal_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - let exp = i & 0x7FF0_0000_0000_0000_i64; - exp.simd_ne(0) & exp.simd_ne(0x7FF0_0000_0000_0000_i64) - } - #[inline(always)] - fn is_sign_positive_f64x8(self, a: f64x8) -> mask64x8 { - let i: i64x8 = a.bitcast(); - (i & i64::MIN).simd_eq(0) - } - #[inline(always)] - fn is_sign_negative_f64x8(self, a: f64x8) -> mask64x8 { - !a.is_sign_positive() - } - #[inline(always)] fn split_f64x8(self, a: f64x8) -> (f64x4, f64x4) { ( f64x4 { @@ -7535,20 +6377,6 @@ impl Simd for WasmSimd128 { ) } #[inline(always)] - fn from_vector_mask64x8(self, vector: i64x8) -> mask64x8 { - mask64x8 { - val: vector.val, - simd: self, - } - } - #[inline(always)] - fn to_vector_mask64x8(self, a: mask64x8) -> i64x8 { - i64x8 { - val: a.val, - simd: self, - } - } - #[inline(always)] fn set_mask64x8(self, a: &mut mask64x8, index: usize, value: bool) -> () { assert!( index < 8usize, @@ -7560,36 +6388,6 @@ impl Simd for WasmSimd128 { *a = lanes.simd_into(self); } #[inline(always)] - fn rotate_elements_left_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_left::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] - fn rotate_elements_right_mask64x8( - self, - a: mask64x8, - ) -> mask64x8 { - let int = i64x8 { - val: crate::transmute::checked_transmute_copy(&a.val), - simd: self, - }; - let rotated = int.rotate_elements_right::(); - mask64x8 { - val: crate::transmute::checked_transmute_copy(&rotated.val), - simd: self, - } - } - #[inline(always)] fn simd_ne_mask64x8(self, a: mask64x8, b: mask64x8) -> mask64x8 { let (a0, a1) = self.split_mask64x8(a); let (b0, b1) = self.split_mask64x8(b); diff --git a/fearless_simd_gen/src/generic.rs b/fearless_simd_gen/src/generic.rs index f6c01186..18ba680b 100644 --- a/fearless_simd_gen/src/generic.rs +++ b/fearless_simd_gen/src/generic.rs @@ -338,6 +338,280 @@ pub(crate) fn pairwise_dot_product_method(op: Op, ty: &VecType) -> TokenStream { } } +/// Implement a mask element rotation without assuming a vector-backed mask +/// representation, so the body is valid for compact predicate masks too. +pub(crate) fn mask_rotate_method( + op: &Op, + vec_ty: &VecType, + direction: ElementDirection, +) -> TokenStream { + let method_sig = op.simd_trait_method_sig(vec_ty); + let rotate = match direction { + ElementDirection::Left => quote! { rotate_elements_left }, + ElementDirection::Right => quote! { rotate_elements_right }, + }; + let mask_ty = vec_ty.rust(); + quote! { + #method_sig { + #mask_ty::from_vector(a.to_vector().#rotate::()) + } + } +} + +/// Implement mask reversal through the corresponding signed integer vector. +pub(crate) fn mask_reverse_method(op: &Op, vec_ty: &VecType) -> TokenStream { + let method_sig = op.simd_trait_method_sig(vec_ty); + let mask_ty = vec_ty.rust(); + quote! { + #method_sig { + #mask_ty::from_vector(a.to_vector().reverse()) + } + } +} + +/// Implement element selection with bitwise operations, without relying on a +/// backend-specific blend intrinsic. +pub(crate) fn select_method(op: &Op, vec_ty: &VecType) -> TokenStream { + let method_sig = op.simd_trait_method_sig(vec_ty); + let int_ty = vec_ty.cast(ScalarType::Int).rust(); + if vec_ty.scalar == ScalarType::Mask { + let mask_ty = vec_ty.rust(); + quote! { + #method_sig { + let mask = a.to_vector(); + let b = b.to_vector(); + let c = c.to_vector(); + #mask_ty::from_vector((mask & b) | (!mask & c)) + } + } + } else { + quote! { + #method_sig { + let mask = a.to_vector(); + let b = b.bitcast::<#int_ty>(); + let c = c.bitcast::<#int_ty>(); + ((mask & b) | (!mask & c)).bitcast() + } + } + } +} + +pub(crate) fn interleave_method(op: &Op, vec_ty: &VecType) -> TokenStream { + let method_sig = op.simd_trait_method_sig(vec_ty); + let zip_low = generic_op_name("zip_low", vec_ty); + let zip_high = generic_op_name("zip_high", vec_ty); + quote! { + #method_sig { + (self.#zip_low(a, b), self.#zip_high(a, b)) + } + } +} + +pub(crate) fn deinterleave_method(op: &Op, vec_ty: &VecType) -> TokenStream { + let method_sig = op.simd_trait_method_sig(vec_ty); + let unzip_low = generic_op_name("unzip_low", vec_ty); + let unzip_high = generic_op_name("unzip_high", vec_ty); + quote! { + #method_sig { + (self.#unzip_low(a, b), self.#unzip_high(a, b)) + } + } +} + +/// Forward element-width-independent bitwise operations through the byte vector. +pub(crate) fn byte_binary_default_op(op: &Op, vec_ty: &VecType) -> TokenStream { + assert_ne!(vec_ty.scalar, ScalarType::Mask); + assert_ne!(*vec_ty, vec_ty.bytes_ty()); + assert!(matches!(op.method, "and" | "or" | "xor")); + let method_sig = op.simd_trait_method_sig(vec_ty); + let byte_method = generic_op_name(op.method, &vec_ty.bytes_ty()); + quote! { + #method_sig { + Bytes::from_bytes(self.#byte_method(Bytes::to_bytes(a), Bytes::to_bytes(b))) + } + } +} + +/// Implement mask bitwise operations through the corresponding integer vector. +pub(crate) fn mask_binary_default_op(op: &Op, vec_ty: &VecType) -> TokenStream { + assert_eq!(vec_ty.scalar, ScalarType::Mask); + let method_sig = op.simd_trait_method_sig(vec_ty); + let mask_ty = vec_ty.rust(); + match op.method { + "and" => quote! { + #method_sig { + #mask_ty::from_vector(a.to_vector() & b.to_vector()) + } + }, + "or" => quote! { + #method_sig { + #mask_ty::from_vector(a.to_vector() | b.to_vector()) + } + }, + "xor" => quote! { + #method_sig { + #mask_ty::from_vector(a.to_vector() ^ b.to_vector()) + } + }, + "not" => quote! { + #method_sig { + #mask_ty::from_vector(!a.to_vector()) + } + }, + _ => unreachable!("mask_binary_default_op only handles bitwise operations"), + } +} + +/// Mask/integer-vector conversions are bitcasts when masks are vector-backed. +pub(crate) fn mask_from_vector_default_op(op: &Op, vec_ty: &VecType) -> TokenStream { + assert_eq!(vec_ty.scalar, ScalarType::Mask); + let method_sig = op.simd_trait_method_sig(vec_ty); + let mask_ty = vec_ty.rust(); + quote! { + #method_sig { + #mask_ty { + val: crate::transmute::checked_transmute_copy(&vector.val), + simd: self, + } + } + } +} + +pub(crate) fn mask_to_vector_default_op(op: &Op, vec_ty: &VecType) -> TokenStream { + assert_eq!(vec_ty.scalar, ScalarType::Mask); + let method_sig = op.simd_trait_method_sig(vec_ty); + let int_ty = vec_ty.cast(ScalarType::Int).rust(); + quote! { + #method_sig { + #int_ty { + val: crate::transmute::checked_transmute_copy(&a.val), + simd: self, + } + } + } +} + +/// Forward typed compression/expansion through bytes using only the public mask +/// conversion methods, so the body is valid for compact predicate masks too. +pub(crate) fn byte_compact_default_op(op: &Op, vec_ty: &VecType) -> TokenStream { + assert_ne!(vec_ty.scalar, ScalarType::Mask); + assert_ne!(*vec_ty, vec_ty.bytes_ty()); + let method_sig = op.simd_trait_method_sig(vec_ty); + let byte_ty = vec_ty.bytes_ty(); + let byte_method = generic_op_name(op.method, &byte_ty); + let byte_mask_ty = byte_ty.mask_ty().rust(); + let byte_int_ty = byte_ty.cast(ScalarType::Int).rust(); + let merge_arg = match op.sig { + OpSig::Compress { merge: true } | OpSig::Expand { merge: true } => { + quote! { , Bytes::to_bytes(merge) } + } + OpSig::Compress { merge: false } | OpSig::Expand { merge: false } => TokenStream::new(), + _ => unreachable!("only compact operations can be forwarded through bytes"), + }; + quote! { + #method_sig { + let mask = #byte_mask_ty::from_vector( + mask.to_vector().bitcast::<#byte_int_ty>(), + ); + Bytes::from_bytes(self.#byte_method(Bytes::to_bytes(values), mask #merge_arg)) + } + } +} + +/// Implementations that can be shared by every backend in the `Simd` trait. +/// +/// These operations are expressed in terms of other `Simd` methods rather than +/// platform intrinsics, so generating a copy in each backend only adds work for +/// the compiler. Backends that have a faster platform-specific formulation +/// override the trait default via [`crate::level::Level::overrides_trait_default`]. +pub(crate) fn trait_default_op(op: &Op, vec_ty: &VecType) -> Option { + let method_sig = op.simd_trait_method_sig(vec_ty); + match op.sig { + OpSig::Unary if op.method == "swap_bytes" && vec_ty.scalar_bits == 8 => { + Some(quote! { #method_sig { a } }) + } + OpSig::Unary + if op.method == "count_zeros" + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned) => + { + let not = generic_op_name("not", vec_ty); + let count_ones = generic_op_name("count_ones", vec_ty); + Some(quote! { + #method_sig { + self.#count_ones(self.#not(a)) + } + }) + } + OpSig::Unary + if op.method == "not" + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned) => + { + Some(quote! { #method_sig { a ^ !0 } }) + } + OpSig::Unary + if op.method == "neg" + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned) => + { + let splat = generic_op_name("splat", vec_ty); + let sub = generic_op_name("sub", vec_ty); + Some(quote! { + #method_sig { + self.#sub(self.#splat(0), a) + } + }) + } + OpSig::UnaryClassify => Some(generic_classify(method_sig, op.method, vec_ty)), + OpSig::Ternary + if op.method == "clamp" + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned) => + { + Some(generic_clamp_int(method_sig)) + } + OpSig::RotateElements { direction } if vec_ty.scalar == ScalarType::Mask => { + Some(mask_rotate_method(op, vec_ty, direction)) + } + OpSig::Unary if op.method == "reverse" && vec_ty.scalar == ScalarType::Mask => { + Some(mask_reverse_method(op, vec_ty)) + } + OpSig::MaskFromVector => Some(mask_from_vector_default_op(op, vec_ty)), + OpSig::MaskToVector => Some(mask_to_vector_default_op(op, vec_ty)), + // Wider vectors keep the existing split/combine default, which avoids + // redundant work on backends whose native width is 128 bits. + OpSig::Select if vec_ty.n_bits() <= 128 => Some(select_method(op, vec_ty)), + OpSig::Binary + if vec_ty.scalar == ScalarType::Mask && matches!(op.method, "and" | "or" | "xor") => + { + Some(mask_binary_default_op(op, vec_ty)) + } + OpSig::Unary if vec_ty.scalar == ScalarType::Mask && matches!(op.method, "not") => { + Some(mask_binary_default_op(op, vec_ty)) + } + OpSig::Binary + if matches!(op.method, "and" | "or" | "xor") + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned) + && *vec_ty != vec_ty.bytes_ty() => + { + Some(byte_binary_default_op(op, vec_ty)) + } + OpSig::Interleave if vec_ty.n_bits() <= 128 => Some(interleave_method(op, vec_ty)), + OpSig::Deinterleave if vec_ty.n_bits() <= 128 => Some(deinterleave_method(op, vec_ty)), + OpSig::Compress { .. } | OpSig::Expand { .. } if vec_ty.scalar != ScalarType::Mask => { + if *vec_ty == vec_ty.bytes_ty() { + Some(generic_op(op, vec_ty)) + } else { + Some(byte_compact_default_op(op, vec_ty)) + } + } + OpSig::WideningBinary { .. } if vec_ty.n_bits() <= 128 => { + Some(widening_binary_method(*op, vec_ty)) + } + OpSig::PairwiseDotProduct { .. } if vec_ty.n_bits() <= 128 => { + Some(pairwise_dot_product_method(*op, vec_ty)) + } + _ => None, + } +} + /// Generic operation implementations. /// /// Most operations are implemented using split/combine, while some forward to diff --git a/fearless_simd_gen/src/level.rs b/fearless_simd_gen/src/level.rs index bfceab7d..6ba00362 100644 --- a/fearless_simd_gen/src/level.rs +++ b/fearless_simd_gen/src/level.rs @@ -5,7 +5,7 @@ use proc_macro2::{Ident, Span, TokenStream}; use quote::{format_ident, quote}; use crate::{ - generic::{generic_mask_casts_methods, generic_op}, + generic::{generic_mask_casts_methods, generic_op, trait_default_op}, ops::{Op, ops_for_type}, types::{SIMD_TYPES, ScalarType, VecType, type_imports}, }; @@ -62,6 +62,12 @@ pub(crate) trait Level { op.sig.should_use_generic_op(vec_ty, self.native_width()) } + /// Whether this backend has a faster implementation than the shared `Simd` + /// trait default for this operation. + fn overrides_trait_default(&self, _op: &Op, _vec_ty: &VecType) -> bool { + false + } + /// Whether this backend overrides equality-mask inversion with native inequality. /// Wider vectors still use the generic split/combine implementation. fn has_native_simd_ne(&self, _vec_ty: &VecType) -> bool { @@ -166,6 +172,8 @@ pub(crate) trait Level { || op.method == "simd_ne" || op.sig.should_route_swizzle_through_bytes(vec_ty) || op.reversed_compare_method().is_some() + || (trait_default_op(&op, vec_ty).is_some() + && !self.overrides_trait_default(&op, vec_ty)) || self.should_use_generic_op(&op, vec_ty) { continue; diff --git a/fearless_simd_gen/src/mk_neon.rs b/fearless_simd_gen/src/mk_neon.rs index 0334d002..dd65a44b 100644 --- a/fearless_simd_gen/src/mk_neon.rs +++ b/fearless_simd_gen/src/mk_neon.rs @@ -1039,6 +1039,20 @@ impl Level for Neon { op.sig.should_use_generic_op(vec_ty, self.native_width()) } } + + fn overrides_trait_default(&self, op: &Op, vec_ty: &VecType) -> bool { + (matches!(op.sig, OpSig::Unary) + && matches!(op.method, "not" | "neg") + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned)) + || matches!( + op.sig, + OpSig::WideningBinary { .. } + | OpSig::PairwiseDotProduct { .. } + | OpSig::Compress { .. } + | OpSig::Expand { .. } + | OpSig::Select + ) + } } impl Neon { diff --git a/fearless_simd_gen/src/mk_simd_trait.rs b/fearless_simd_gen/src/mk_simd_trait.rs index dbdc93df..5509f01b 100644 --- a/fearless_simd_gen/src/mk_simd_trait.rs +++ b/fearless_simd_gen/src/mk_simd_trait.rs @@ -7,7 +7,7 @@ use quote::{format_ident, quote}; use crate::{ generic::{ byte_swizzle_op, generic_mask_cast_body, generic_mask_casts_methods, generic_op, - generic_op_name, reversed_compare_op, + generic_op_name, reversed_compare_op, trait_default_op, }, ops::{ CoreOpTrait, OpKind, OpSig, TyFlavor, base_trait_ops, ops_for_type, overloaded_ops_for, @@ -61,6 +61,13 @@ pub(crate) fn mk_simd_trait() -> TokenStream { #[inline(always)] #method }); + } else if let Some(method) = trait_default_op(&op, vec_ty) { + methods.extend(quote! { + #[doc = #doc] + #doc_alias + #[inline(always)] + #method + }); } else if op.sig.should_use_generic_op(vec_ty, 128) { let method = generic_op(&op, vec_ty); methods.extend(quote! { @@ -288,10 +295,20 @@ fn mk_simd_base() -> TokenStream { for op in base_trait_ops() { let doc = op.format_docstring(TyFlavor::VecImpl); if let Some(method_sig) = op.vec_trait_method_sig() { - methods.push(quote! { - #[doc = #doc] - #method_sig; - }); + if op.method == "splat" { + methods.push(quote! { + #[doc = #doc] + #[inline(always)] + #method_sig { + Self::simd_from(simd, val) + } + }); + } else { + methods.push(quote! { + #[doc = #doc] + #method_sig; + }); + } } } let overloaded_ops = [CoreOpTrait::Add, CoreOpTrait::Sub, CoreOpTrait::Mul]; @@ -357,17 +374,33 @@ fn mk_simd_base() -> TokenStream { + IntoIterator + AsRef<[Self::Element]> + AsMut<[Self::Element]> + + for<'a> TryFrom<&'a [Self::Element]> + From; - fn as_slice(&self) -> &[Self::Element]; - fn as_mut_slice(&mut self) -> &mut [Self::Element]; + #[inline(always)] + fn as_slice(&self) -> &[Self::Element] { + self.as_array().as_ref() + } + #[inline(always)] + fn as_mut_slice(&mut self) -> &mut [Self::Element] { + self.as_mut_array().as_mut() + } /// Create a SIMD vector from a slice. /// /// The slice must be exactly the size of the SIMD vector. - fn from_slice(simd: S, slice: &[Self::Element]) -> Self; + #[inline(always)] + fn from_slice(simd: S, slice: &[Self::Element]) -> Self { + Self::load_array( + simd, + slice.try_into().unwrap_or_else(|_| unreachable!()), + ) + } /// Store a SIMD vector into a slice. /// /// The slice must be exactly the size of the SIMD vector. - fn store_slice(&self, slice: &mut [Self::Element]); + #[inline(always)] + fn store_slice(&self, slice: &mut [Self::Element]) { + slice.copy_from_slice(self.as_array().as_ref()); + } /// Create a SIMD vector from its corresponding lane array. #[inline(always)] fn load_array(simd: S, val: Self::Array) -> Self { @@ -648,12 +681,18 @@ fn mk_simd_mask() -> TokenStream { /// Create a SIMD mask from signed integer mask lanes. /// /// The slice must be exactly the size of the SIMD mask. - fn from_slice(simd: S, slice: &[Self::Element]) -> Self; + #[inline(always)] + fn from_slice(simd: S, slice: &[Self::Element]) -> Self { + Self::from_vector(Self::Ints::from_slice(simd, slice)) + } /// Store this SIMD mask as signed integer mask lanes. /// /// The slice must be exactly the size of the SIMD mask. - fn store_slice(&self, slice: &mut [Self::Element]); + #[inline(always)] + fn store_slice(&self, slice: &mut [Self::Element]) { + self.to_vector().store_slice(slice); + } #( #methods )* } diff --git a/fearless_simd_gen/src/mk_simd_types.rs b/fearless_simd_gen/src/mk_simd_types.rs index d7dd5bf1..9496ccf2 100644 --- a/fearless_simd_gen/src/mk_simd_types.rs +++ b/fearless_simd_gen/src/mk_simd_types.rs @@ -558,18 +558,6 @@ fn simd_mask_impl(ty: &VecType) -> TokenStream { self.simd.#set_op(self, index, value); } - #[inline(always)] - fn from_slice(simd: S, slice: &[#scalar]) -> Self { - let slice: &[#scalar; #len] = slice.try_into().unwrap(); - Self::simd_from(simd, *slice) - } - - #[inline(always)] - fn store_slice(&self, slice: &mut [#scalar]) { - let slice: &mut [#scalar; #len] = slice.try_into().unwrap(); - *slice = (*self).into(); - } - #( #methods )* } } @@ -581,7 +569,6 @@ fn simd_vec_impl(ty: &VecType) -> TokenStream { let byte_vector = ty.bytes_ty().rust(); let len = Literal::usize_unsuffixed(ty.len); let from_fn_items = unrolled_array(ty.len, |idx| quote! { f(#idx) }); - let splat = generic_op_name("splat", ty); let mut base_methods = vec![]; for op in base_trait_ops() { let Op { sig, method, .. } = op; @@ -658,31 +645,6 @@ fn simd_vec_impl(ty: &VecType) -> TokenStream { type Block = #block_ty; type Array = [#scalar; #len]; - #[inline(always)] - fn as_slice(&self) -> &[#scalar] { - self.as_array().as_slice() - } - - #[inline(always)] - fn as_mut_slice(&mut self) -> &mut [#scalar] { - self.as_mut_array().as_mut_slice() - } - - #[inline(always)] - fn from_slice(simd: S, slice: &[#scalar]) -> Self { - Self::load_array_ref(simd, slice.try_into().unwrap()) - } - - #[inline(always)] - fn store_slice(&self, slice: &mut [#scalar]) { - (*self).store_array(slice.try_into().unwrap()); - } - - #[inline(always)] - fn splat(simd: S, val: #scalar) -> Self { - simd.#splat(val) - } - #[inline(always)] fn block_splat(block: Self::Block) -> Self { #block_splat_body diff --git a/fearless_simd_gen/src/mk_wasm.rs b/fearless_simd_gen/src/mk_wasm.rs index f7f5326f..d606a7fb 100644 --- a/fearless_simd_gen/src/mk_wasm.rs +++ b/fearless_simd_gen/src/mk_wasm.rs @@ -483,6 +483,19 @@ impl Level for WasmSimd128 { true } + fn overrides_trait_default(&self, op: &Op, vec_ty: &VecType) -> bool { + (matches!(op.sig, OpSig::Unary) + && matches!(op.method, "not" | "neg") + && matches!(vec_ty.scalar, ScalarType::Int | ScalarType::Unsigned)) + || (matches!(op.sig, OpSig::PairwiseDotProduct { .. }) + && vec_ty.scalar == ScalarType::Int + && vec_ty.scalar_bits == 16) + || matches!( + op.sig, + OpSig::Compress { .. } | OpSig::Expand { .. } | OpSig::Select + ) + } + fn make_method(&self, op: Op, vec_ty: &VecType) -> TokenStream { let Op { sig, method, .. } = op; diff --git a/fearless_simd_gen/src/mk_x86.rs b/fearless_simd_gen/src/mk_x86.rs index 5fb6eda2..0b4a7c39 100644 --- a/fearless_simd_gen/src/mk_x86.rs +++ b/fearless_simd_gen/src/mk_x86.rs @@ -319,6 +319,41 @@ impl Level for X86 { *self == Self::Avx512 || vec_ty.scalar == ScalarType::Float } + fn overrides_trait_default(&self, op: &Op, vec_ty: &VecType) -> bool { + match op.sig { + OpSig::RotateElements { .. } => *self == Self::Avx512, + OpSig::Unary if op.method == "reverse" => { + *self == Self::Avx512 && vec_ty.scalar == ScalarType::Mask + } + OpSig::UnaryClassify => *self == Self::Avx512, + OpSig::Unary if op.method == "count_zeros" => *self == Self::Sse2, + // x86 has fused interleave/deinterleave and negation kernels; keep them + // instead of expanding the individual zip/unzip or splat-and-sub steps. + OpSig::Interleave | OpSig::Deinterleave => true, + OpSig::Unary if op.method == "neg" => true, + OpSig::WideningBinary { .. } => self.prefers_native_widening_binary(op, vec_ty), + OpSig::PairwiseDotProduct { .. } => { + vec_ty.scalar == ScalarType::Int && vec_ty.scalar_bits == 16 + } + OpSig::Compress { .. } | OpSig::Expand { .. } => self.has_native_compact(op, vec_ty), + OpSig::Binary + if vec_ty.scalar == ScalarType::Mask + && matches!(op.method, "and" | "or" | "xor") => + { + *self == Self::Avx512 + } + OpSig::Unary if vec_ty.scalar == ScalarType::Mask && op.method == "not" => { + *self == Self::Avx512 + } + OpSig::MaskFromVector | OpSig::MaskToVector => *self == Self::Avx512, + // All x86 levels have a hand-written select; SSE4.2 and AVX2 use a + // single blend instruction, which the shared bitwise formula cannot + // reproduce. + OpSig::Select => true, + _ => false, + } + } + fn make_method(&self, op: Op, vec_ty: &VecType) -> TokenStream { let Op { sig, method, .. } = op; let method_sig = op.simd_trait_method_sig(vec_ty); @@ -3041,7 +3076,38 @@ impl X86 { }) } - fn handle_widening_binary(&self, op: Op, vec_ty: &VecType, target_ty: VecType) -> TokenStream { + /// Whether this backend has a native or hand-written compact path rather + /// than the shared byte-forwarding/scalar implementation. + fn has_native_compact(&self, op: &Op, vec_ty: &VecType) -> bool { + if *self == Self::Avx512 { + return true; + } + if *self == Self::Avx2 && vec_ty.n_bits() == 512 && matches!(vec_ty.scalar_bits, 32 | 64) { + return true; + } + if *self == Self::Avx2 && vec_ty.n_bits() == 256 && matches!(vec_ty.scalar_bits, 32 | 64) { + return true; + } + if matches!(*self, Self::Sse4_2 | Self::Avx2) + && vec_ty.n_bits() == 128 + && matches!(vec_ty.scalar_bits, 16 | 32 | 64) + { + return true; + } + if *vec_ty != vec_ty.bytes_ty() { + return false; + } + if matches!(*self, Self::Sse4_2 | Self::Avx2) && vec_ty.len == 16 { + return true; + } + if *self == Self::Avx2 && matches!(op.sig, OpSig::Compress { .. }) { + return true; + } + matches!(*self, Self::Sse4_2 | Self::Avx2) + } + + /// Which native widening-arithmetic formulation this backend uses, if any. + fn native_widening_binary_kind(&self, op: &Op, vec_ty: &VecType) -> (bool, bool) { // PMADDUBSW with one byte operand set to 1 gives exact byte sums: // [-256, 254] for signed bytes, [0, 510] for unsigned bytes. Neither // reaches its i16 saturation limits. PMADDWD similarly sums signed words. @@ -3063,6 +3129,17 @@ impl X86 { (32, ScalarType::Int, Self::Sse4_2 | Self::Avx2) => true, _ => false, }; + (pairwise_add, widening_mul) + } + + /// Whether this backend has a native formulation for widening arithmetic. + fn prefers_native_widening_binary(&self, op: &Op, vec_ty: &VecType) -> bool { + let (pairwise_add, widening_mul) = self.native_widening_binary_kind(op, vec_ty); + pairwise_add || widening_mul + } + + fn handle_widening_binary(&self, op: Op, vec_ty: &VecType, target_ty: VecType) -> TokenStream { + let (pairwise_add, widening_mul) = self.native_widening_binary_kind(&op, vec_ty); if !pairwise_add && !widening_mul { return crate::generic::widening_binary_method(op, vec_ty); }