From c948b703ff57f25a1a41be5e03553065454080b9 Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Tue, 1 Aug 2023 07:58:44 -0400 Subject: [PATCH] Simplify signed leading_ones/trailing_ones --- crates/core_simd/src/elements/int.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/core_simd/src/elements/int.rs b/crates/core_simd/src/elements/int.rs index 6992b679515..e81ed7bf601 100644 --- a/crates/core_simd/src/elements/int.rs +++ b/crates/core_simd/src/elements/int.rs @@ -213,7 +213,7 @@ pub trait SimdInt: Copy + Sealed { } macro_rules! impl_trait { - { $($ty:ident ($unsigned:ident)),* } => { + { $($ty:ty),* } => { $( impl Sealed for Simd<$ty, LANES> where @@ -353,18 +353,16 @@ fn trailing_zeros(self) -> Self { #[inline] fn leading_ones(self) -> Self { - use crate::simd::SimdUint; - self.cast::<$unsigned>().leading_ones().cast() + (!self).leading_zeros() } #[inline] fn trailing_ones(self) -> Self { - use crate::simd::SimdUint; - self.cast::<$unsigned>().trailing_ones().cast() + (!self).trailing_zeros() } } )* } } -impl_trait! { i8 (u8), i16 (u16), i32 (u32), i64 (u64), isize (usize) } +impl_trait! { i8, i16, i32, i64, isize }