]> git.lizzy.rs Git - rust.git/blob - src/test/ui/simd/intrinsic/generic-reduction.rs
Auto merge of #95454 - randomicon00:fix95444, r=wesleywiser
[rust.git] / src / test / ui / simd / intrinsic / generic-reduction.rs
1 // build-fail
2 // ignore-emscripten
3
4 // Test that the simd_reduce_{op} intrinsics produce ok-ish error
5 // messages when misused.
6
7 #![feature(repr_simd, platform_intrinsics)]
8 #![allow(non_camel_case_types)]
9
10 #[repr(simd)]
11 #[derive(Copy, Clone)]
12 pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
13
14 #[repr(simd)]
15 #[derive(Copy, Clone)]
16 pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
17
18
19 extern "platform-intrinsic" {
20     fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U;
21     fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U;
22     fn simd_reduce_and<T, U>(x: T) -> U;
23     fn simd_reduce_or<T, U>(x: T) -> U;
24     fn simd_reduce_xor<T, U>(x: T) -> U;
25     fn simd_reduce_all<T>(x: T) -> bool;
26     fn simd_reduce_any<T>(x: T) -> bool;
27 }
28
29 fn main() {
30     let x = u32x4(0, 0, 0, 0);
31     let z = f32x4(0.0, 0.0, 0.0, 0.0);
32
33     unsafe {
34         simd_reduce_add_ordered(z, 0);
35         //~^ ERROR expected return type `f32` (element of input `f32x4`), found `i32`
36         simd_reduce_mul_ordered(z, 1);
37         //~^ ERROR expected return type `f32` (element of input `f32x4`), found `i32`
38
39         let _: f32 = simd_reduce_and(x);
40         //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32`
41         let _: f32 = simd_reduce_or(x);
42         //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32`
43         let _: f32 = simd_reduce_xor(x);
44         //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32`
45
46         let _: f32 = simd_reduce_and(z);
47         //~^ ERROR unsupported simd_reduce_and from `f32x4` with element `f32` to `f32`
48         let _: f32 = simd_reduce_or(z);
49         //~^ ERROR unsupported simd_reduce_or from `f32x4` with element `f32` to `f32`
50         let _: f32 = simd_reduce_xor(z);
51         //~^ ERROR unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32`
52
53         let _: bool = simd_reduce_all(z);
54         //~^ ERROR unsupported simd_reduce_all from `f32x4` with element `f32` to `bool`
55         let _: bool = simd_reduce_any(z);
56         //~^ ERROR unsupported simd_reduce_any from `f32x4` with element `f32` to `bool`
57     }
58 }