Skip to content

Commit 50ef985

Browse files
authored
Rollup merge of #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 #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?
2 parents d09523d + 038f4e2 commit 50ef985

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]);

tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fabs;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fabs<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @fabs_32x2
2926
#[no_mangle]
3027
pub unsafe fn fabs_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_ceil;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_ceil<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @ceil_32x2
2926
#[no_mangle]
3027
pub unsafe fn ceil_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fcos;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fcos<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @fcos_32x2
2926
#[no_mangle]
3027
pub unsafe fn fcos_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fexp;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fexp<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @exp_32x2
2926
#[no_mangle]
3027
pub unsafe fn exp_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fexp2;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fexp2<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @exp2_32x2
2926
#[no_mangle]
3027
pub unsafe fn exp2_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_floor;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_floor<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @floor_32x2
2926
#[no_mangle]
3027
pub unsafe fn floor_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fma;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fma<T>(x: T, b: T, c: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @fma_32x2
2926
#[no_mangle]
3027
pub unsafe fn fma_32x2(a: f32x2, b: f32x2, c: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fsqrt;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fsqrt<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @fsqrt_32x2
2926
#[no_mangle]
3027
pub unsafe fn fsqrt_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_flog;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_flog<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @log_32x2
2926
#[no_mangle]
3027
pub unsafe fn log_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_flog10;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_flog10<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @log10_32x2
2926
#[no_mangle]
3027
pub unsafe fn log10_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_flog2;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_flog2<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @log2_32x2
2926
#[no_mangle]
3027
pub unsafe fn log2_32x2(a: f32x2) -> f32x2 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::{simd_fmax, simd_fmin};
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x4(pub [f32; 4]);
1112

12-
extern "rust-intrinsic" {
13-
fn simd_fmin<T>(x: T, y: T) -> T;
14-
fn simd_fmax<T>(x: T, y: T) -> T;
15-
}
16-
1713
// CHECK-LABEL: @fmin
1814
#[no_mangle]
1915
pub unsafe fn fmin(a: f32x4, b: f32x4) -> f32x4 {

tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//@ compile-flags: -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
4-
5-
#![feature(repr_simd, intrinsics)]
4+
#![feature(repr_simd, core_intrinsics)]
65
#![allow(non_camel_case_types)]
76

7+
use std::intrinsics::simd::simd_fsin;
8+
89
#[repr(simd)]
910
#[derive(Copy, Clone, PartialEq, Debug)]
1011
pub struct f32x2(pub [f32; 2]);
@@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]);
2122
#[derive(Copy, Clone, PartialEq, Debug)]
2223
pub struct f32x16(pub [f32; 16]);
2324

24-
extern "rust-intrinsic" {
25-
fn simd_fsin<T>(x: T) -> T;
26-
}
27-
2825
// CHECK-LABEL: @fsin_32x2
2926
#[no_mangle]
3027
pub unsafe fn fsin_32x2(a: f32x2) -> f32x2 {

0 commit comments

Comments
 (0)