]> git.lizzy.rs Git - rust.git/blob - src/test/ui/simd/intrinsic/generic-arithmetic-2.rs
Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser
[rust.git] / src / test / ui / simd / intrinsic / generic-arithmetic-2.rs
1 // build-fail
2
3 #![feature(repr_simd, platform_intrinsics)]
4 #![allow(non_camel_case_types)]
5 #[repr(simd)]
6 #[derive(Copy, Clone)]
7 pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
8
9 #[repr(simd)]
10 #[derive(Copy, Clone)]
11 pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
12
13 #[repr(simd)]
14 #[derive(Copy, Clone)]
15 pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
16
17 extern "platform-intrinsic" {
18     fn simd_add<T>(x: T, y: T) -> T;
19     fn simd_sub<T>(x: T, y: T) -> T;
20     fn simd_mul<T>(x: T, y: T) -> T;
21     fn simd_div<T>(x: T, y: T) -> T;
22     fn simd_rem<T>(x: T, y: T) -> T;
23     fn simd_shl<T>(x: T, y: T) -> T;
24     fn simd_shr<T>(x: T, y: T) -> T;
25     fn simd_and<T>(x: T, y: T) -> T;
26     fn simd_or<T>(x: T, y: T) -> T;
27     fn simd_xor<T>(x: T, y: T) -> T;
28
29     fn simd_neg<T>(x: T) -> T;
30 }
31
32 fn main() {
33     let x = i32x4(0, 0, 0, 0);
34     let y = u32x4(0, 0, 0, 0);
35     let z = f32x4(0.0, 0.0, 0.0, 0.0);
36
37     unsafe {
38         simd_add(x, x);
39         simd_add(y, y);
40         simd_add(z, z);
41         simd_sub(x, x);
42         simd_sub(y, y);
43         simd_sub(z, z);
44         simd_mul(x, x);
45         simd_mul(y, y);
46         simd_mul(z, z);
47         simd_div(x, x);
48         simd_div(y, y);
49         simd_div(z, z);
50         simd_rem(x, x);
51         simd_rem(y, y);
52         simd_rem(z, z);
53
54         simd_shl(x, x);
55         simd_shl(y, y);
56         simd_shr(x, x);
57         simd_shr(y, y);
58         simd_and(x, x);
59         simd_and(y, y);
60         simd_or(x, x);
61         simd_or(y, y);
62         simd_xor(x, x);
63         simd_xor(y, y);
64
65         simd_neg(x);
66         simd_neg(z);
67
68
69         simd_add(0, 0);
70         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
71         simd_sub(0, 0);
72         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
73         simd_mul(0, 0);
74         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
75         simd_div(0, 0);
76         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
77         simd_shl(0, 0);
78         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
79         simd_shr(0, 0);
80         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
81         simd_and(0, 0);
82         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
83         simd_or(0, 0);
84         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
85         simd_xor(0, 0);
86         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
87
88         simd_neg(0);
89         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
90
91
92         simd_shl(z, z);
93 //~^ ERROR unsupported operation on `f32x4` with element `f32`
94         simd_shr(z, z);
95 //~^ ERROR unsupported operation on `f32x4` with element `f32`
96         simd_and(z, z);
97 //~^ ERROR unsupported operation on `f32x4` with element `f32`
98         simd_or(z, z);
99 //~^ ERROR unsupported operation on `f32x4` with element `f32`
100         simd_xor(z, z);
101 //~^ ERROR unsupported operation on `f32x4` with element `f32`
102     }
103 }