Skip to content

Commit b2e1bcb

Browse files
Merge pull request #391 from RalfJung/core-intrinsics
use core::intrinsics::simd
2 parents f505736 + 851ef63 commit b2e1bcb

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

crates/std_float/src/lib.rs

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(feature = "as_crate", no_std)] // We are std!
22
#![cfg_attr(
33
feature = "as_crate",
4-
feature(platform_intrinsics),
4+
feature(core_intrinsics),
55
feature(portable_simd),
66
allow(internal_features)
77
)]
@@ -10,6 +10,8 @@ use core::simd;
1010
#[cfg(feature = "as_crate")]
1111
use core_simd::simd;
1212

13+
use core::intrinsics::simd as intrinsics;
14+
1315
use simd::{LaneCount, Simd, SupportedLaneCount};
1416

1517
#[cfg(feature = "as_crate")]
@@ -22,28 +24,6 @@ use experimental as sealed;
2224

2325
use crate::sealed::Sealed;
2426

25-
// "platform intrinsics" are essentially "codegen intrinsics"
26-
// each of these may be scalarized and lowered to a libm call
27-
extern "platform-intrinsic" {
28-
// ceil
29-
fn simd_ceil<T>(x: T) -> T;
30-
31-
// floor
32-
fn simd_floor<T>(x: T) -> T;
33-
34-
// round
35-
fn simd_round<T>(x: T) -> T;
36-
37-
// trunc
38-
fn simd_trunc<T>(x: T) -> T;
39-
40-
// fsqrt
41-
fn simd_fsqrt<T>(x: T) -> T;
42-
43-
// fma
44-
fn simd_fma<T>(x: T, y: T, z: T) -> T;
45-
}
46-
4727
/// This trait provides a possibly-temporary implementation of float functions
4828
/// that may, in the absence of hardware support, canonicalize to calling an
4929
/// operating system's `math.h` dynamically-loaded library (also known as a
@@ -74,43 +54,43 @@ pub trait StdFloat: Sealed + Sized {
7454
#[inline]
7555
#[must_use = "method returns a new vector and does not mutate the original value"]
7656
fn mul_add(self, a: Self, b: Self) -> Self {
77-
unsafe { simd_fma(self, a, b) }
57+
unsafe { intrinsics::simd_fma(self, a, b) }
7858
}
7959

8060
/// Produces a vector where every lane has the square root value
8161
/// of the equivalently-indexed lane in `self`
8262
#[inline]
8363
#[must_use = "method returns a new vector and does not mutate the original value"]
8464
fn sqrt(self) -> Self {
85-
unsafe { simd_fsqrt(self) }
65+
unsafe { intrinsics::simd_fsqrt(self) }
8666
}
8767

8868
/// Returns the smallest integer greater than or equal to each lane.
8969
#[must_use = "method returns a new vector and does not mutate the original value"]
9070
#[inline]
9171
fn ceil(self) -> Self {
92-
unsafe { simd_ceil(self) }
72+
unsafe { intrinsics::simd_ceil(self) }
9373
}
9474

9575
/// Returns the largest integer value less than or equal to each lane.
9676
#[must_use = "method returns a new vector and does not mutate the original value"]
9777
#[inline]
9878
fn floor(self) -> Self {
99-
unsafe { simd_floor(self) }
79+
unsafe { intrinsics::simd_floor(self) }
10080
}
10181

10282
/// Rounds to the nearest integer value. Ties round toward zero.
10383
#[must_use = "method returns a new vector and does not mutate the original value"]
10484
#[inline]
10585
fn round(self) -> Self {
106-
unsafe { simd_round(self) }
86+
unsafe { intrinsics::simd_round(self) }
10787
}
10888

10989
/// Returns the floating point's integer value, with its fractional part removed.
11090
#[must_use = "method returns a new vector and does not mutate the original value"]
11191
#[inline]
11292
fn trunc(self) -> Self {
113-
unsafe { simd_trunc(self) }
93+
unsafe { intrinsics::simd_trunc(self) }
11494
}
11595

11696
/// Returns the floating point's fractional value, with its integer part removed.

0 commit comments

Comments
 (0)