]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/simd-intrinsic-generic-comparison.rs
Add #[rustc_no_mir] to make tests pass with -Z orbit.
[rust.git] / src / test / compile-fail / simd-intrinsic-generic-comparison.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(repr_simd, platform_intrinsics, rustc_attrs)]
12
13 #[repr(simd)]
14 #[derive(Copy, Clone)]
15 #[allow(non_camel_case_types)]
16 struct i32x4(i32, i32, i32, i32);
17 #[repr(simd)]
18 #[derive(Copy, Clone)]
19 #[allow(non_camel_case_types)]
20 struct i16x8(i16, i16, i16, i16,
21              i16, i16, i16, i16);
22
23 extern "platform-intrinsic" {
24     fn simd_eq<T, U>(x: T, y: T) -> U;
25     fn simd_ne<T, U>(x: T, y: T) -> U;
26     fn simd_lt<T, U>(x: T, y: T) -> U;
27     fn simd_le<T, U>(x: T, y: T) -> U;
28     fn simd_gt<T, U>(x: T, y: T) -> U;
29     fn simd_ge<T, U>(x: T, y: T) -> U;
30 }
31
32 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
33 fn main() {
34     let x = i32x4(0, 0, 0, 0);
35
36     unsafe {
37         simd_eq::<i32, i32>(0, 0);
38         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
39         simd_ne::<i32, i32>(0, 0);
40         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
41         simd_lt::<i32, i32>(0, 0);
42         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
43         simd_le::<i32, i32>(0, 0);
44         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
45         simd_gt::<i32, i32>(0, 0);
46         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
47         simd_ge::<i32, i32>(0, 0);
48         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
49
50         simd_eq::<_, i32>(x, x);
51         //~^ ERROR expected SIMD return type, found non-SIMD `i32`
52         simd_ne::<_, i32>(x, x);
53         //~^ ERROR expected SIMD return type, found non-SIMD `i32`
54         simd_lt::<_, i32>(x, x);
55         //~^ ERROR expected SIMD return type, found non-SIMD `i32`
56         simd_le::<_, i32>(x, x);
57         //~^ ERROR expected SIMD return type, found non-SIMD `i32`
58         simd_gt::<_, i32>(x, x);
59         //~^ ERROR expected SIMD return type, found non-SIMD `i32`
60         simd_ge::<_, i32>(x, x);
61         //~^ ERROR expected SIMD return type, found non-SIMD `i32`
62
63         simd_eq::<_, i16x8>(x, x);
64 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8
65         simd_ne::<_, i16x8>(x, x);
66 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8
67         simd_lt::<_, i16x8>(x, x);
68 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8
69         simd_le::<_, i16x8>(x, x);
70 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8
71         simd_gt::<_, i16x8>(x, x);
72 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8
73         simd_ge::<_, i16x8>(x, x);
74 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8
75     }
76 }