diff options
| author | bors <bors@rust-lang.org> | 2022-02-03 09:15:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-03 09:15:16 +0000 |
| commit | 796bf14f2e129283d9daee7f05d14c2dfa76d643 (patch) | |
| tree | 5574b5f443c0dcd292507bf907c083a0bb7535fe /src | |
| parent | 1be5c8f90912c446ecbdc405cbc4a89f9acd20fd (diff) | |
| parent | e96159e9af4e55070481a7c071e61e0adf337807 (diff) | |
| download | rust-796bf14f2e129283d9daee7f05d14c2dfa76d643.tar.gz rust-796bf14f2e129283d9daee7f05d14c2dfa76d643.zip | |
Auto merge of #93146 - workingjubilee:use-std-simd, r=Mark-Simulacrum
pub use std::simd::StdFloat;
Syncs portable-simd up to commit rust-lang/portable-simd@03f6fbb21e6050da2a05b3ce8f480c020b384916,
Diff: https://github.com/rust-lang/portable-simd/compare/533f0fc81ab9ba097779fcd27c8f9ea12261fef5...03f6fbb21e6050da2a05b3ce8f480c020b384916
This sync requires a little bit more legwork because it also introduces a trait into `std::simd`, so that it is no longer simply a reexport of `core::simd`. Out of simple-minded consistency and to allow more options, I replicated the pattern for the way `core::simd` is integrated in the first place, however this is not necessary if it doesn't acquire any interdependencies inside `std`: it could be a simple crate reexport. I just don't know yet if that will happen or not.
To summarize other misc changes:
- Shifts no longer panic, now wrap on too-large shifts (like `Simd` integers usually do!)
- mask16x32 will now be many i16s, not many i32s... 🙃
- `#[must_use]` is spread around generously
- Adjusts division, float min/max, and `Mask::{from,to}_array` internally to be faster
- Adds the much-requested `Simd::cast::<U>` function (equivalent to `simd.to_array().map(|lane| lane as U)`)
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/simd/libm_std_can_float.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/simd/portable-intrinsics-arent-exposed.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/simd/portable-intrinsics-arent-exposed.stderr | 23 |
3 files changed, 37 insertions, 12 deletions
diff --git a/src/test/ui/simd/libm_std_can_float.rs b/src/test/ui/simd/libm_std_can_float.rs new file mode 100644 index 00000000000..6a844e7120e --- /dev/null +++ b/src/test/ui/simd/libm_std_can_float.rs @@ -0,0 +1,23 @@ +// run-pass + +// This is the converse of the other libm test. +#![feature(portable_simd)] +use std::simd::f32x4; +use std::simd::StdFloat; + +// For SIMD float ops, the LLIR version which is used to implement the portable +// forms of them may become calls to math.h AKA libm. So, we can't guarantee +// we can compile them for #![no_std] crates. +// +// However, we can expose some of these ops via an extension trait. +fn main() { + let x = f32x4::from_array([0.1, 0.5, 0.6, -1.5]); + let x2 = x + x; + let _xc = x.ceil(); + let _xf = x.floor(); + let _xr = x.round(); + let _xt = x.trunc(); + let _xfma = x.mul_add(x, x); + let _xsqrt = x.sqrt(); + let _ = x2.abs() * x2; +} diff --git a/src/test/ui/simd/portable-intrinsics-arent-exposed.rs b/src/test/ui/simd/portable-intrinsics-arent-exposed.rs index 4d759032355..667c8b67b1d 100644 --- a/src/test/ui/simd/portable-intrinsics-arent-exposed.rs +++ b/src/test/ui/simd/portable-intrinsics-arent-exposed.rs @@ -1,7 +1,8 @@ // May not matter, since people can use them with a nightly feature. // However this tests to guarantee they don't leak out via portable_simd, // and thus don't accidentally get stabilized. -use std::simd::intrinsics; //~ERROR E0603 +use core::simd::intrinsics; //~ERROR E0433 +use std::simd::intrinsics; //~ERROR E0432 fn main() { () diff --git a/src/test/ui/simd/portable-intrinsics-arent-exposed.stderr b/src/test/ui/simd/portable-intrinsics-arent-exposed.stderr index 9ac73eca193..f568aa04295 100644 --- a/src/test/ui/simd/portable-intrinsics-arent-exposed.stderr +++ b/src/test/ui/simd/portable-intrinsics-arent-exposed.stderr @@ -1,15 +1,16 @@ -error[E0603]: module `intrinsics` is private - --> $DIR/portable-intrinsics-arent-exposed.rs:4:16 +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/portable-intrinsics-arent-exposed.rs:4:5 | -LL | use std::simd::intrinsics; - | ^^^^^^^^^^ private module - | -note: the module `intrinsics` is defined here - --> $SRC_DIR/core/src/lib.rs:LL:COL +LL | use core::simd::intrinsics; + | ^^^^ maybe a missing crate `core`? + +error[E0432]: unresolved import `std::simd::intrinsics` + --> $DIR/portable-intrinsics-arent-exposed.rs:5:5 | -LL | pub use crate::core_simd::simd::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | use std::simd::intrinsics; + | ^^^^^^^^^^^^^^^^^^^^^ no `intrinsics` in `simd` -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0603`. +Some errors have detailed explanations: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. |
