Merge pull request #224 from rust-lang/feature/min-max-intrinsic

Use intrinsic for min/max
This commit is contained in:
Caleb Zulawski 2022-01-13 20:22:00 -05:00 committed by GitHub
commit 41db15373a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -46,6 +46,10 @@ extern "platform-intrinsic" {
/// fabs
pub(crate) fn simd_fabs<T>(x: T) -> T;
// minnum/maxnum
pub(crate) fn simd_fmin<T>(x: T, y: T) -> T;
pub(crate) fn simd_fmax<T>(x: T, y: 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

@ -141,11 +141,7 @@ macro_rules! impl_float_vector {
#[inline]
#[must_use = "method returns a new vector and does not mutate the original value"]
pub fn min(self, other: Self) -> Self {
// TODO consider using an intrinsic
self.is_nan().select(
other,
self.lanes_ge(other).select(other, self)
)
unsafe { intrinsics::simd_fmin(self, other) }
}
/// Returns the maximum of each lane.
@ -154,11 +150,7 @@ macro_rules! impl_float_vector {
#[inline]
#[must_use = "method returns a new vector and does not mutate the original value"]
pub fn max(self, other: Self) -> Self {
// TODO consider using an intrinsic
self.is_nan().select(
other,
self.lanes_le(other).select(other, self)
)
unsafe { intrinsics::simd_fmax(self, other) }
}
/// Restrict each lane to a certain interval unless it is NaN.