Skip to content

Commit 06814be

Browse files
Use fabs intrinsic
1 parent 6620015 commit 06814be

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/core_simd/src/intrinsics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ extern "platform-intrinsic" {
4848
#[cfg(feature = "std")]
4949
pub(crate) fn simd_ceil<T>(x: T) -> T;
5050

51+
/// fabs
52+
pub(crate) fn simd_fabs<T>(x: T) -> T;
53+
5154
pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;
5255
pub(crate) fn simd_ne<T, U>(x: T, y: T) -> U;
5356
pub(crate) fn simd_lt<T, U>(x: T, y: T) -> U;

crates/core_simd/src/vector/float.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ macro_rules! impl_float_vector {
3232
/// equivalently-indexed lane in `self`.
3333
#[inline]
3434
pub fn abs(self) -> Self {
35-
let no_sign = crate::$bits_ty::splat(!0 >> 1);
36-
Self::from_bits(self.to_bits() & no_sign)
35+
unsafe { crate::intrinsics::simd_fabs(self) }
3736
}
3837
}
3938
};

0 commit comments

Comments
 (0)