Use fabs intrinsic

This commit is contained in:
Jubilee Young 2021-04-13 19:24:20 -07:00 committed by Caleb Zulawski
parent e73985f25d
commit 9acc112090
2 changed files with 4 additions and 2 deletions

View File

@ -51,6 +51,9 @@ extern "platform-intrinsic" {
#[cfg(feature = "std")]
pub(crate) fn simd_ceil<T>(x: T) -> T;
/// fabs
pub(crate) fn simd_fabs<T>(x: T) -> T;
pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_ne<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_lt<T, U>(x: T, y: T) -> U;

View File

@ -32,8 +32,7 @@ macro_rules! impl_float_vector {
/// equivalently-indexed lane in `self`.
#[inline]
pub fn abs(self) -> Self {
let no_sign = crate::$bits_ty::splat(!0 >> 1);
Self::from_bits(self.to_bits() & no_sign)
unsafe { crate::intrinsics::simd_fabs(self) }
}
}