X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=library%2Fportable-simd%2Fcrates%2Fcore_simd%2Fsrc%2Fmath.rs;h=7435b6df9186098a4e1ce5c3b4f8b61ae0a8316b;hb=b9f7197ab35f79b4df1f60104b9d8af9e77bb566;hp=2bae414ebfb5494621051e09554287683b3e10a7;hpb=9f1f42897d0e0ae580f2e49a1b46fad27b60990e;p=rust.git diff --git a/library/portable-simd/crates/core_simd/src/math.rs b/library/portable-simd/crates/core_simd/src/math.rs index 2bae414ebfb..7435b6df918 100644 --- a/library/portable-simd/crates/core_simd/src/math.rs +++ b/library/portable-simd/crates/core_simd/src/math.rs @@ -17,7 +17,7 @@ macro_rules! impl_uint_arith { /// let max = Simd::splat(MAX); /// let unsat = x + max; /// let sat = x.saturating_add(max); - /// assert_eq!(x - 1, unsat); + /// assert_eq!(unsat, Simd::from_array([1, 0, MAX, MAX - 1])); /// assert_eq!(sat, max); /// ``` #[inline] @@ -37,7 +37,7 @@ pub fn saturating_add(self, second: Self) -> Self { /// let max = Simd::splat(MAX); /// let unsat = x - max; /// let sat = x.saturating_sub(max); - /// assert_eq!(unsat, x + 1); + /// assert_eq!(unsat, Simd::from_array([3, 2, 1, 0])); /// assert_eq!(sat, Simd::splat(0)); #[inline] pub fn saturating_sub(self, second: Self) -> Self { @@ -105,7 +105,7 @@ pub fn saturating_sub(self, second: Self) -> Self { #[inline] pub fn abs(self) -> Self { const SHR: $ty = <$ty>::BITS as $ty - 1; - let m = self >> SHR; + let m = self >> Simd::splat(SHR); (self^m) - m } @@ -128,7 +128,7 @@ pub fn abs(self) -> Self { pub fn saturating_abs(self) -> Self { // arith shift for -1 or 0 mask based on sign bit, giving 2s complement const SHR: $ty = <$ty>::BITS as $ty - 1; - let m = self >> SHR; + let m = self >> Simd::splat(SHR); (self^m).saturating_sub(m) }