]> git.proxmox.com Git - rustc.git/blame - src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / simd-intrinsic / simd-intrinsic-generic-elements.rs
CommitLineData
dfeec247
XL
1// build-fail
2
54a0048b 3#![feature(repr_simd, platform_intrinsics, rustc_attrs)]
e9174d1e
SL
4
5#[repr(simd)]
6#[derive(Copy, Clone)]
7#[allow(non_camel_case_types)]
8struct i32x2(i32, i32);
9#[repr(simd)]
10#[derive(Copy, Clone)]
11#[allow(non_camel_case_types)]
e9174d1e
SL
12struct i32x4(i32, i32, i32, i32);
13#[repr(simd)]
14#[derive(Copy, Clone)]
15#[allow(non_camel_case_types)]
16struct i32x8(i32, i32, i32, i32,
17 i32, i32, i32, i32);
18
19#[repr(simd)]
20#[derive(Copy, Clone)]
21#[allow(non_camel_case_types)]
22struct f32x2(f32, f32);
23#[repr(simd)]
24#[derive(Copy, Clone)]
25#[allow(non_camel_case_types)]
e9174d1e
SL
26struct f32x4(f32, f32, f32, f32);
27#[repr(simd)]
28#[derive(Copy, Clone)]
29#[allow(non_camel_case_types)]
30struct f32x8(f32, f32, f32, f32,
31 f32, f32, f32, f32);
32
33extern "platform-intrinsic" {
34 fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
35 fn simd_extract<T, E>(x: T, idx: u32) -> E;
36
37 fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
e9174d1e
SL
38 fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
39 fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
40}
41
42fn main() {
43 let x = i32x4(0, 0, 0, 0);
44
45 unsafe {
46 simd_insert(0, 0, 0);
47 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
48 simd_insert(x, 0, 1.0);
49 //~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64`
50 simd_extract::<_, f32>(x, 0);
51 //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32`
52
53 simd_shuffle2::<i32, i32>(0, 0, [0; 2]);
54 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
e9174d1e
SL
55 simd_shuffle4::<i32, i32>(0, 0, [0; 4]);
56 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
57 simd_shuffle8::<i32, i32>(0, 0, [0; 8]);
58 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
59
60 simd_shuffle2::<_, f32x2>(x, x, [0; 2]);
61//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
e9174d1e
SL
62 simd_shuffle4::<_, f32x4>(x, x, [0; 4]);
63//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
64 simd_shuffle8::<_, f32x8>(x, x, [0; 8]);
65//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
66
67 simd_shuffle2::<_, i32x8>(x, x, [0; 2]);
68 //~^ ERROR expected return type of length 2, found `i32x8` with length 8
6a06907d
XL
69 simd_shuffle4::<_, i32x8>(x, x, [0; 4]);
70 //~^ ERROR expected return type of length 4, found `i32x8` with length 8
e9174d1e
SL
71 simd_shuffle8::<_, i32x2>(x, x, [0; 8]);
72 //~^ ERROR expected return type of length 8, found `i32x2` with length 2
73 }
74}