Merge pull request #95 from rust-lang/intrinsic-fabs

Use fabs intrinsic
This commit is contained in:
Caleb Zulawski 2021-04-19 01:46:52 -04:00 committed by GitHub
commit b2e25bc8c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) }
}
}