Skip to content

Port ui/simd tests to use the intrinsic macro #136022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tests/ui/simd/array-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ pub struct T<S: Simd>([S::Lane; S::SIZE]);
//~| ERROR SIMD vector element type should be a primitive scalar
//~| ERROR unconstrained generic constant

extern "rust-intrinsic" {
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
fn simd_extract<T, E>(x: T, idx: u32) -> E;
}
#[rustc_intrinsic]
unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;

#[rustc_intrinsic]
unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E;


pub fn main() {
let mut t = T::<i32x4>([0; 4]);
Expand Down
10 changes: 6 additions & 4 deletions tests/ui/simd/array-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ struct S([i32; 4]);
#[derive(Copy, Clone)]
struct T<const N: usize>([i32; N]);

extern "rust-intrinsic" {
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
fn simd_extract<T, E>(x: T, idx: u32) -> E;
}
#[rustc_intrinsic]
unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;

#[rustc_intrinsic]
unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E;


pub fn main() {
let mut s = S([0; 4]);
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/simd/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ struct B<T>([T; 4]);
struct C<T, const N: usize>([T; N]);


extern "rust-intrinsic" {
fn simd_add<T>(x: T, y: T) -> T;
}
#[rustc_intrinsic]
unsafe fn simd_add<T>(x: T, y: T) -> T;

fn add<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T {
lhs + rhs
Expand Down
74 changes: 53 additions & 21 deletions tests/ui/simd/intrinsic/float-math-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,59 @@
#[derive(Copy, Clone, PartialEq, Debug)]
struct f32x4(pub [f32; 4]);

extern "rust-intrinsic" {
fn simd_fsqrt<T>(x: T) -> T;
fn simd_fabs<T>(x: T) -> T;
fn simd_fsin<T>(x: T) -> T;
fn simd_fcos<T>(x: T) -> T;
fn simd_fexp<T>(x: T) -> T;
fn simd_fexp2<T>(x: T) -> T;
fn simd_fma<T>(x: T, y: T, z: T) -> T;
fn simd_relaxed_fma<T>(x: T, y: T, z: T) -> T;
fn simd_flog<T>(x: T) -> T;
fn simd_flog10<T>(x: T) -> T;
fn simd_flog2<T>(x: T) -> T;
fn simd_fpow<T>(x: T, y: T) -> T;
fn simd_fpowi<T>(x: T, y: i32) -> T;

// rounding functions
fn simd_ceil<T>(x: T) -> T;
fn simd_floor<T>(x: T) -> T;
fn simd_round<T>(x: T) -> T;
fn simd_trunc<T>(x: T) -> T;
}
#[rustc_intrinsic]
unsafe fn simd_fsqrt<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fabs<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fsin<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fcos<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fexp<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fexp2<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fma<T>(x: T, y: T, z: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_relaxed_fma<T>(x: T, y: T, z: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_flog<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_flog10<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_flog2<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fpow<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_fpowi<T>(x: T, y: i32) -> T;


// rounding functions
#[rustc_intrinsic]
unsafe fn simd_ceil<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_floor<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_round<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_trunc<T>(x: T) -> T;


macro_rules! assert_approx_eq_f32 {
($a:expr, $b:expr) => ({
Expand Down
67 changes: 48 additions & 19 deletions tests/ui/simd/intrinsic/generic-arithmetic-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,54 @@ pub struct u32x4(pub [u32; 4]);
#[derive(Copy, Clone)]
pub struct f32x4(pub [f32; 4]);

extern "rust-intrinsic" {
fn simd_add<T>(x: T, y: T) -> T;
fn simd_sub<T>(x: T, y: T) -> T;
fn simd_mul<T>(x: T, y: T) -> T;
fn simd_div<T>(x: T, y: T) -> T;
fn simd_rem<T>(x: T, y: T) -> T;
fn simd_shl<T>(x: T, y: T) -> T;
fn simd_shr<T>(x: T, y: T) -> T;
fn simd_and<T>(x: T, y: T) -> T;
fn simd_or<T>(x: T, y: T) -> T;
fn simd_xor<T>(x: T, y: T) -> T;

fn simd_neg<T>(x: T) -> T;
fn simd_bswap<T>(x: T) -> T;
fn simd_bitreverse<T>(x: T) -> T;
fn simd_ctlz<T>(x: T) -> T;
fn simd_ctpop<T>(x: T) -> T;
fn simd_cttz<T>(x: T) -> T;
}
#[rustc_intrinsic]
unsafe fn simd_add<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_sub<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_mul<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_div<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_rem<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_shl<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_shr<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_and<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_or<T>(x: T, y: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_xor<T>(x: T, y: T) -> T;


#[rustc_intrinsic]
unsafe fn simd_neg<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_bswap<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_bitreverse<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_ctlz<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_ctpop<T>(x: T) -> T;

#[rustc_intrinsic]
unsafe fn simd_cttz<T>(x: T) -> T;

fn main() {
let x = i32x4([0, 0, 0, 0]);
Expand Down
48 changes: 24 additions & 24 deletions tests/ui/simd/intrinsic/generic-arithmetic-2.stderr
Original file line number Diff line number Diff line change
@@ -1,143 +1,143 @@
error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:81:9
--> $DIR/generic-arithmetic-2.rs:110:9
|
LL | simd_add(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:83:9
--> $DIR/generic-arithmetic-2.rs:112:9
|
LL | simd_sub(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:85:9
--> $DIR/generic-arithmetic-2.rs:114:9
|
LL | simd_mul(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:87:9
--> $DIR/generic-arithmetic-2.rs:116:9
|
LL | simd_div(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:89:9
--> $DIR/generic-arithmetic-2.rs:118:9
|
LL | simd_shl(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:91:9
--> $DIR/generic-arithmetic-2.rs:120:9
|
LL | simd_shr(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:93:9
--> $DIR/generic-arithmetic-2.rs:122:9
|
LL | simd_and(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:95:9
--> $DIR/generic-arithmetic-2.rs:124:9
|
LL | simd_or(0, 0);
| ^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:97:9
--> $DIR/generic-arithmetic-2.rs:126:9
|
LL | simd_xor(0, 0);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:100:9
--> $DIR/generic-arithmetic-2.rs:129:9
|
LL | simd_neg(0);
| ^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:102:9
--> $DIR/generic-arithmetic-2.rs:131:9
|
LL | simd_bswap(0);
| ^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:104:9
--> $DIR/generic-arithmetic-2.rs:133:9
|
LL | simd_bitreverse(0);
| ^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:106:9
--> $DIR/generic-arithmetic-2.rs:135:9
|
LL | simd_ctlz(0);
| ^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-arithmetic-2.rs:108:9
--> $DIR/generic-arithmetic-2.rs:137:9
|
LL | simd_cttz(0);
| ^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:111:9
--> $DIR/generic-arithmetic-2.rs:140:9
|
LL | simd_shl(z, z);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:113:9
--> $DIR/generic-arithmetic-2.rs:142:9
|
LL | simd_shr(z, z);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:115:9
--> $DIR/generic-arithmetic-2.rs:144:9
|
LL | simd_and(z, z);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:117:9
--> $DIR/generic-arithmetic-2.rs:146:9
|
LL | simd_or(z, z);
| ^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:119:9
--> $DIR/generic-arithmetic-2.rs:148:9
|
LL | simd_xor(z, z);
| ^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:121:9
--> $DIR/generic-arithmetic-2.rs:150:9
|
LL | simd_bswap(z);
| ^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:123:9
--> $DIR/generic-arithmetic-2.rs:152:9
|
LL | simd_bitreverse(z);
| ^^^^^^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:125:9
--> $DIR/generic-arithmetic-2.rs:154:9
|
LL | simd_ctlz(z);
| ^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:127:9
--> $DIR/generic-arithmetic-2.rs:156:9
|
LL | simd_ctpop(z);
| ^^^^^^^^^^^^^

error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32`
--> $DIR/generic-arithmetic-2.rs:129:9
--> $DIR/generic-arithmetic-2.rs:158:9
|
LL | simd_cttz(z);
| ^^^^^^^^^^^^
Expand Down
Loading
Loading