Skip to content

Commit 50ef985

Browse files
authoredFeb 28, 2025
Rollup merge of rust-lang#137551 - folkertdev:import-simd-intrinsics, r=RalfJung
import `simd_` intrinsics In most cases, we can import the simd intrinsics rather than redeclare them. Apparently, most of these tests were written before `std::intrinsics::simd` existed. There are a couple of exceptions where we can't yet import: - the intrinsics are not declared as `const fn` in the standard library, causing issues in the `const-eval` tests - the `simd_shuffle_generic` function is not exposed from `std::intrinsics` - the `simd_fpow` and `simd_fpowi` functions are not exposed from `std::intrinsics` (removed in rust-lang#137595) - some tests use `no_core`, and therefore cannot use `std::intrinsics` r? ```@RalfJung``` cc ```@workingjubilee``` do you have context on why some intrinsics are not exposed?

File tree

85 files changed

+477
-1024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+477
-1024
lines changed
 

‎library/core/src/intrinsics/simd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/// `idx` must be in-bounds of the vector.
1212
#[rustc_intrinsic]
1313
#[rustc_nounwind]
14-
pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T;
14+
pub const unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T;
1515

1616
/// Extracts an element from a vector.
1717
///
@@ -22,7 +22,7 @@ pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T;
2222
/// `idx` must be in-bounds of the vector.
2323
#[rustc_intrinsic]
2424
#[rustc_nounwind]
25-
pub unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U;
25+
pub const unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U;
2626

2727
/// Adds two simd vectors elementwise.
2828
///

‎tests/codegen/issues/issue-84268.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//@ compile-flags: -Copt-level=3 --crate-type=rlib
2-
#![feature(intrinsics, repr_simd)]
2+
#![feature(core_intrinsics, repr_simd)]
33

4-
extern "rust-intrinsic" {
5-
fn simd_fabs<T>(x: T) -> T;
6-
fn simd_eq<T, U>(x: T, y: T) -> U;
7-
}
4+
use std::intrinsics::simd::{simd_eq, simd_fabs};
85

96
#[repr(simd)]
107
pub struct V([f32; 4]);

0 commit comments

Comments
 (0)
Please sign in to comment.