4 // Test that the simd_reduce_{op} intrinsics produce ok-ish error
5 // messages when misused.
7 #![feature(repr_simd, platform_intrinsics)]
8 #![allow(non_camel_case_types)]
11 #[derive(Copy, Clone)]
12 pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
15 #[derive(Copy, Clone)]
16 pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
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;
30 let x = u32x4(0, 0, 0, 0);
31 let z = f32x4(0.0, 0.0, 0.0, 0.0);
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`
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`
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`
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`