diff options
| author | Caleb Zulawski <caleb.zulawski@gmail.com> | 2021-09-11 14:47:28 +0000 |
|---|---|---|
| committer | Caleb Zulawski <caleb.zulawski@gmail.com> | 2021-09-11 14:55:14 +0000 |
| commit | 1b3fe755ea3d39a1875f627fab5def4eae03e912 (patch) | |
| tree | a2fc1b6f1ffd29360478062716f30da422eb7945 /src/test/ui/simd | |
| parent | b69fe57261086e70aea9d5b58819a1794bf7c121 (diff) | |
| download | rust-1b3fe755ea3d39a1875f627fab5def4eae03e912.tar.gz rust-1b3fe755ea3d39a1875f627fab5def4eae03e912.zip | |
Allow simd_shuffle to accept vectors of any length
Diffstat (limited to 'src/test/ui/simd')
| -rw-r--r-- | src/test/ui/simd/shuffle-not-out-of-bounds.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/simd/shuffle-not-out-of-bounds.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/simd/shuffle.rs | 24 |
3 files changed, 41 insertions, 1 deletions
diff --git a/src/test/ui/simd/shuffle-not-out-of-bounds.rs b/src/test/ui/simd/shuffle-not-out-of-bounds.rs index 8a533453e75..aae6ce4663f 100644 --- a/src/test/ui/simd/shuffle-not-out-of-bounds.rs +++ b/src/test/ui/simd/shuffle-not-out-of-bounds.rs @@ -188,4 +188,14 @@ fn main() { 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); + + extern "platform-intrinsic" { + fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; + } + let v = u8x2(0, 0); + const I: [u32; 2] = [4, 4]; + unsafe { + let _: u8x2 = simd_shuffle(v, v, I); + //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic + } } diff --git a/src/test/ui/simd/shuffle-not-out-of-bounds.stderr b/src/test/ui/simd/shuffle-not-out-of-bounds.stderr index 07253a4ae46..737fb5e6e51 100644 --- a/src/test/ui/simd/shuffle-not-out-of-bounds.stderr +++ b/src/test/ui/simd/shuffle-not-out-of-bounds.stderr @@ -71,6 +71,12 @@ LL | | 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4) + --> $DIR/shuffle-not-out-of-bounds.rs:198:23 + | +LL | let _: u8x2 = simd_shuffle(v, v, I); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/shuffle.rs b/src/test/ui/simd/shuffle.rs new file mode 100644 index 00000000000..3592adfdc6a --- /dev/null +++ b/src/test/ui/simd/shuffle.rs @@ -0,0 +1,24 @@ +//run-pass +#![feature(repr_simd, platform_intrinsics)] + +extern "platform-intrinsic" { + fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; +} + +#[derive(Copy, Clone)] +#[repr(simd)] +struct Simd<T, const N: usize>([T; N]); + +fn main() { + const I1: [u32; 4] = [0, 2, 4, 6]; + const I2: [u32; 2] = [1, 5]; + let a = Simd::<u8, 4>([0, 1, 2, 3]); + let b = Simd::<u8, 4>([4, 5, 6, 7]); + unsafe { + let x: Simd<u8, 4> = simd_shuffle(a, b, I1); + assert_eq!(x.0, [0, 2, 4, 6]); + + let y: Simd<u8, 2> = simd_shuffle(a, b, I2); + assert_eq!(y.0, [1, 5]); + } +} |
