]> git.lizzy.rs Git - rust.git/blob - src/test/ui/simd/simd-size-align.rs
556013788c33557c0b81445d0b3d5d235d1dd5a5
[rust.git] / src / test / ui / simd / simd-size-align.rs
1 // run-pass
2 #![allow(deprecated)]
3
4
5 #![feature(repr_simd)]
6 #![allow(non_camel_case_types)]
7
8 use std::mem;
9
10 /// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec<T>` properly
11 /// Please consult the issue #20460
12 fn check<T>() {
13     assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0)
14 }
15
16 fn main() {
17     check::<u8x2>();
18     check::<u8x3>();
19     check::<u8x4>();
20     check::<u8x5>();
21     check::<u8x6>();
22     check::<u8x7>();
23     check::<u8x8>();
24
25     check::<i16x2>();
26     check::<i16x3>();
27     check::<i16x4>();
28     check::<i16x5>();
29     check::<i16x6>();
30     check::<i16x7>();
31     check::<i16x8>();
32
33     check::<f32x2>();
34     check::<f32x3>();
35     check::<f32x4>();
36     check::<f32x5>();
37     check::<f32x6>();
38     check::<f32x7>();
39     check::<f32x8>();
40
41     check::<usizex2>();
42     check::<usizex3>();
43     check::<usizex4>();
44     check::<usizex5>();
45     check::<usizex6>();
46     check::<usizex7>();
47     check::<usizex8>();
48
49     check::<isizex2>();
50     check::<isizex3>();
51     check::<isizex4>();
52     check::<isizex5>();
53     check::<isizex6>();
54     check::<isizex7>();
55     check::<isizex8>();
56 }
57
58 #[repr(simd)] struct u8x2(u8, u8);
59 #[repr(simd)] struct u8x3(u8, u8, u8);
60 #[repr(simd)] struct u8x4(u8, u8, u8, u8);
61 #[repr(simd)] struct u8x5(u8, u8, u8, u8, u8);
62 #[repr(simd)] struct u8x6(u8, u8, u8, u8, u8, u8);
63 #[repr(simd)] struct u8x7(u8, u8, u8, u8, u8, u8, u8);
64 #[repr(simd)] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8);
65
66 #[repr(simd)] struct i16x2(i16, i16);
67 #[repr(simd)] struct i16x3(i16, i16, i16);
68 #[repr(simd)] struct i16x4(i16, i16, i16, i16);
69 #[repr(simd)] struct i16x5(i16, i16, i16, i16, i16);
70 #[repr(simd)] struct i16x6(i16, i16, i16, i16, i16, i16);
71 #[repr(simd)] struct i16x7(i16, i16, i16, i16, i16, i16, i16);
72 #[repr(simd)] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
73
74 #[repr(simd)] struct f32x2(f32, f32);
75 #[repr(simd)] struct f32x3(f32, f32, f32);
76 #[repr(simd)] struct f32x4(f32, f32, f32, f32);
77 #[repr(simd)] struct f32x5(f32, f32, f32, f32, f32);
78 #[repr(simd)] struct f32x6(f32, f32, f32, f32, f32, f32);
79 #[repr(simd)] struct f32x7(f32, f32, f32, f32, f32, f32, f32);
80 #[repr(simd)] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32);
81
82 #[repr(simd)] struct usizex2(usize, usize);
83 #[repr(simd)] struct usizex3(usize, usize, usize);
84 #[repr(simd)] struct usizex4(usize, usize, usize, usize);
85 #[repr(simd)] struct usizex5(usize, usize, usize, usize, usize);
86 #[repr(simd)] struct usizex6(usize, usize, usize, usize, usize, usize);
87 #[repr(simd)] struct usizex7(usize, usize, usize, usize, usize, usize, usize);
88 #[repr(simd)] struct usizex8(usize, usize, usize, usize, usize, usize, usize, usize);
89
90 #[repr(simd)] struct isizex2(isize, isize);
91 #[repr(simd)] struct isizex3(isize, isize, isize);
92 #[repr(simd)] struct isizex4(isize, isize, isize, isize);
93 #[repr(simd)] struct isizex5(isize, isize, isize, isize, isize);
94 #[repr(simd)] struct isizex6(isize, isize, isize, isize, isize, isize);
95 #[repr(simd)] struct isizex7(isize, isize, isize, isize, isize, isize, isize);
96 #[repr(simd)] struct isizex8(isize, isize, isize, isize, isize, isize, isize, isize);