2 #![allow(non_camel_case_types)]
3 #![feature(repr_simd, platform_intrinsics)]
5 // Test for #73542 to verify out-of-bounds shuffle vectors do not compile.
12 #[derive(Copy, Clone)]
13 struct u8x4(u8, u8, u8, u8);
16 #[derive(Copy, Clone)]
17 struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8);
20 #[derive(Copy, Clone)]
41 #[derive(Copy, Clone)]
78 #[derive(Copy, Clone)]
146 // Test vectors by lane size. Since LLVM does not distinguish between a shuffle
147 // over two f32s and a shuffle over two u64s, or any other such combination,
148 // it is not necessary to test every possible vector, only lane counts.
149 macro_rules! test_shuffle_lanes {
150 ($n:literal, $x:ident, $y:ident, $t:tt) => {
153 const ARR: [u32; $n] = {
154 let mut arr = [0; $n];
158 extern "platform-intrinsic" {
159 pub fn $y<T, U>(x: T, y: T, idx: [u32; $n]) -> U;
168 //~^^^^^ ERROR: invalid monomorphization of `simd_shuffle2` intrinsic
169 //~| ERROR: invalid monomorphization of `simd_shuffle4` intrinsic
170 //~| ERROR: invalid monomorphization of `simd_shuffle8` intrinsic
171 //~| ERROR: invalid monomorphization of `simd_shuffle16` intrinsic
172 //~| ERROR: invalid monomorphization of `simd_shuffle32` intrinsic
173 //~| ERROR: invalid monomorphization of `simd_shuffle64` intrinsic
174 // Because the test is mostly embedded in a macro, all the errors have the same origin point.
175 // And unfortunately, standard comments, as in the UI test harness, disappear in macros!
178 test_shuffle_lanes!(2, u8x2, simd_shuffle2, (2, 1));
179 test_shuffle_lanes!(4, u8x4, simd_shuffle4, (4, 3, 2, 1));
180 test_shuffle_lanes!(8, u8x8, simd_shuffle8, (8, 7, 6, 5, 4, 3, 2, 1));
181 test_shuffle_lanes!(16, u8x16, simd_shuffle16,
182 (16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
183 test_shuffle_lanes!(32, u8x32, simd_shuffle32,
184 (32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16,
185 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
186 test_shuffle_lanes!(64, u8x64, simd_shuffle64,
187 (64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49,
188 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33,
189 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
190 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));