diff options
| author | bors <bors@rust-lang.org> | 2021-10-10 22:25:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-10 22:25:49 +0000 |
| commit | 3bf55753c680e653eaa9d11dd66e56844bd04d32 (patch) | |
| tree | 2470e75ee0c0d29e7627aebc87c0c232d057a93a /src/test/ui/simd | |
| parent | 41dfaaa3c66759395835b3af59b22f4f22175dc8 (diff) | |
| parent | 2a7b5117eabab43cb03d69b120b5ff965464ea71 (diff) | |
| download | rust-3bf55753c680e653eaa9d11dd66e56844bd04d32.tar.gz rust-3bf55753c680e653eaa9d11dd66e56844bd04d32.zip | |
Auto merge of #89541 - workingjubilee:abbrev-shufvec-t, r=Mark-Simulacrum
Cleanup src/test/ui/{simd,simd-intrinsic}
Initial motivation was to simplify a huge macro expansion using a tuple, since we can just use an array in `#[repr(simd)]` now for the same result. But also, several tests were going unnoticed during development of SIMD intrinsics because people kept looking in the wrong directory, and many are basically run-pass vs. build-fail versions of the same tests, so let's keep them close together and simplify their names, so they're easier to sift through.
Diffstat (limited to 'src/test/ui/simd')
| -rw-r--r-- | src/test/ui/simd/array-trait.rs (renamed from src/test/ui/simd/simd-array-trait.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/array-trait.stderr (renamed from src/test/ui/simd/simd-array-trait.stderr) | 2 | ||||
| -rw-r--r-- | src/test/ui/simd/array-type.rs (renamed from src/test/ui/simd/simd-array-type.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/generics.rs (renamed from src/test/ui/simd/simd-generics.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/float-math-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-float-math.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/float-minmax-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-float-minmax.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-arithmetic-2.rs | 103 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-arithmetic-2.stderr | 93 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-arithmetic-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs | 38 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr | 15 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-bitmask-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-bitmask.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-bitmask.rs | 69 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-bitmask.stderr | 33 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-cast-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-cast.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-cast.rs | 43 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-cast.stderr | 27 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-comparison-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-comparison.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-comparison.rs | 67 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-comparison.stderr | 111 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-elements-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-elements.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-elements.rs | 77 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-elements.stderr | 75 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-gather-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-gather.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-reduction-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-reduction.rs) | 9 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-reduction.rs | 58 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-reduction.stderr | 63 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-select-pass.rs (renamed from src/test/ui/simd/simd-intrinsic-generic-select.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-select.rs | 64 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-select.stderr | 51 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-shuffle.rs | 33 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/generic-shuffle.stderr | 21 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/inlining-issue67557-ice.rs | 26 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/inlining-issue67557.rs | 42 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/issue-85855.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/simd/intrinsic/issue-85855.stderr | 21 | ||||
| -rw-r--r-- | src/test/ui/simd/shuffle-not-out-of-bounds.rs | 168 | ||||
| -rw-r--r-- | src/test/ui/simd/shuffle-not-out-of-bounds.stderr | 57 | ||||
| -rw-r--r-- | src/test/ui/simd/size-align.rs (renamed from src/test/ui/simd/simd-size-align.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/target-feature-mixup.rs (renamed from src/test/ui/simd/simd-target-feature-mixup.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-empty.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-empty.stderr (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-extern-nonnull-ptr.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-non-primitive.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-non-primitive.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-non-primitive.stderr (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-non-primitive.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-oversized.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-oversized.stderr (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-power-of-two.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-wide-ptr.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-wide-ptr.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation-wide-ptr.stderr (renamed from src/test/ui/simd/simd-type-generic-monomorphisation-wide-ptr.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation.rs (renamed from src/test/ui/simd/simd-type-generic-monomorphisation.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-generic-monomorphisation.stderr (renamed from src/test/ui/simd/simd-type-generic-monomorphisation.stderr) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-len.rs (renamed from src/test/ui/simd/simd-type.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-len.stderr (renamed from src/test/ui/simd/simd-type.stderr) | 12 | ||||
| -rw-r--r-- | src/test/ui/simd/type-wide-ptr.rs (renamed from src/test/ui/simd/simd-type-wide-ptr.rs) | 0 | ||||
| -rw-r--r-- | src/test/ui/simd/type-wide-ptr.stderr (renamed from src/test/ui/simd/simd-type-wide-ptr.stderr) | 0 |
57 files changed, 1208 insertions, 189 deletions
diff --git a/src/test/ui/simd/simd-array-trait.rs b/src/test/ui/simd/array-trait.rs index 45c10b37816..45c10b37816 100644 --- a/src/test/ui/simd/simd-array-trait.rs +++ b/src/test/ui/simd/array-trait.rs diff --git a/src/test/ui/simd/simd-array-trait.stderr b/src/test/ui/simd/array-trait.stderr index 0e02883f67a..765215c3939 100644 --- a/src/test/ui/simd/simd-array-trait.stderr +++ b/src/test/ui/simd/array-trait.stderr @@ -1,5 +1,5 @@ error: unconstrained generic constant - --> $DIR/simd-array-trait.rs:23:23 + --> $DIR/array-trait.rs:23:23 | LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/simd/simd-array-type.rs b/src/test/ui/simd/array-type.rs index 7d66395a3c8..7d66395a3c8 100644 --- a/src/test/ui/simd/simd-array-type.rs +++ b/src/test/ui/simd/array-type.rs diff --git a/src/test/ui/simd/simd-generics.rs b/src/test/ui/simd/generics.rs index fa9d35ee4df..fa9d35ee4df 100644 --- a/src/test/ui/simd/simd-generics.rs +++ b/src/test/ui/simd/generics.rs diff --git a/src/test/ui/simd/simd-intrinsic-float-math.rs b/src/test/ui/simd/intrinsic/float-math-pass.rs index 7a4f7466559..7a4f7466559 100644 --- a/src/test/ui/simd/simd-intrinsic-float-math.rs +++ b/src/test/ui/simd/intrinsic/float-math-pass.rs diff --git a/src/test/ui/simd/simd-intrinsic-float-minmax.rs b/src/test/ui/simd/intrinsic/float-minmax-pass.rs index d79be61f909..d79be61f909 100644 --- a/src/test/ui/simd/simd-intrinsic-float-minmax.rs +++ b/src/test/ui/simd/intrinsic/float-minmax-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-arithmetic-2.rs b/src/test/ui/simd/intrinsic/generic-arithmetic-2.rs new file mode 100644 index 00000000000..3576eed71ab --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -0,0 +1,103 @@ +// build-fail + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct i32x4(pub i32, pub i32, pub i32, pub i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +extern "platform-intrinsic" { + fn simd_add<T>(x: T, y: T) -> T; + fn simd_sub<T>(x: T, y: T) -> T; + fn simd_mul<T>(x: T, y: T) -> T; + fn simd_div<T>(x: T, y: T) -> T; + fn simd_rem<T>(x: T, y: T) -> T; + fn simd_shl<T>(x: T, y: T) -> T; + fn simd_shr<T>(x: T, y: T) -> T; + fn simd_and<T>(x: T, y: T) -> T; + fn simd_or<T>(x: T, y: T) -> T; + fn simd_xor<T>(x: T, y: T) -> T; + + fn simd_neg<T>(x: T) -> T; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + let y = u32x4(0, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_add(x, x); + simd_add(y, y); + simd_add(z, z); + simd_sub(x, x); + simd_sub(y, y); + simd_sub(z, z); + simd_mul(x, x); + simd_mul(y, y); + simd_mul(z, z); + simd_div(x, x); + simd_div(y, y); + simd_div(z, z); + simd_rem(x, x); + simd_rem(y, y); + simd_rem(z, z); + + simd_shl(x, x); + simd_shl(y, y); + simd_shr(x, x); + simd_shr(y, y); + simd_and(x, x); + simd_and(y, y); + simd_or(x, x); + simd_or(y, y); + simd_xor(x, x); + simd_xor(y, y); + + simd_neg(x); + simd_neg(z); + + + simd_add(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_sub(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_mul(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_div(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shl(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shr(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_and(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_or(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_xor(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + simd_neg(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + + simd_shl(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_shr(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_and(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_or(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_xor(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + } +} diff --git a/src/test/ui/simd/intrinsic/generic-arithmetic-2.stderr b/src/test/ui/simd/intrinsic/generic-arithmetic-2.stderr new file mode 100644 index 00000000000..0f0a7ea6652 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -0,0 +1,93 @@ +error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:69:9 + | +LL | simd_add(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:71:9 + | +LL | simd_sub(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:73:9 + | +LL | simd_mul(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:75:9 + | +LL | simd_div(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:77:9 + | +LL | simd_shl(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:79:9 + | +LL | simd_shr(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:81:9 + | +LL | simd_and(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:83:9 + | +LL | simd_or(0, 0); + | ^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:85:9 + | +LL | simd_xor(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:88:9 + | +LL | simd_neg(0); + | ^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:92:9 + | +LL | simd_shl(z, z); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:94:9 + | +LL | simd_shr(z, z); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:96:9 + | +LL | simd_and(z, z); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:98:9 + | +LL | simd_or(z, z); + | ^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:100:9 + | +LL | simd_xor(z, z); + | ^^^^^^^^^^^^^^ + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs b/src/test/ui/simd/intrinsic/generic-arithmetic-pass.rs index c507b8d31ec..c507b8d31ec 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-arithmetic.rs +++ b/src/test/ui/simd/intrinsic/generic-arithmetic-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs b/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs new file mode 100644 index 00000000000..9736d1b964d --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs @@ -0,0 +1,38 @@ +// build-fail +// ignore-emscripten +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct i32x4(pub i32, pub i32, pub i32, pub i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct x4<T>(pub T, pub T, pub T, pub T); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +extern "platform-intrinsic" { + fn simd_saturating_add<T>(x: T, y: T) -> T; + fn simd_saturating_sub<T>(x: T, y: T) -> T; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + let y = x4(0_usize, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_saturating_add(x, x); + simd_saturating_add(y, y); + simd_saturating_sub(x, x); + simd_saturating_sub(y, y); + + simd_saturating_add(z, z); + //~^ ERROR expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type + simd_saturating_sub(z, z); + //~^ ERROR expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type + } +} diff --git a/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr b/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr new file mode 100644 index 00000000000..f349cb56560 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr @@ -0,0 +1,15 @@ +error[E0511]: invalid monomorphization of `simd_saturating_add` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type + --> $DIR/generic-arithmetic-saturating-2.rs:33:9 + | +LL | simd_saturating_add(z, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_saturating_sub` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type + --> $DIR/generic-arithmetic-saturating-2.rs:35:9 + | +LL | simd_saturating_sub(z, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs b/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs index c11d14b99d4..c11d14b99d4 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs +++ b/src/test/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs diff --git a/src/test/ui/simd/simd-intrinsic-generic-bitmask.rs b/src/test/ui/simd/intrinsic/generic-bitmask-pass.rs index 8c436841b44..8c436841b44 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-bitmask.rs +++ b/src/test/ui/simd/intrinsic/generic-bitmask-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-bitmask.rs b/src/test/ui/simd/intrinsic/generic-bitmask.rs new file mode 100644 index 00000000000..92c4e67dfdd --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-bitmask.rs @@ -0,0 +1,69 @@ +// build-fail + +// Test that the simd_bitmask intrinsic produces ok-ish error +// messages when misused. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x2([u32; 2]); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4([u32; 4]); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u8x8([u8; 8]); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u8x16([u8; 16]); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u8x32([u8; 32]); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u8x64([u8; 64]); + +extern "platform-intrinsic" { + fn simd_bitmask<T, U>(x: T) -> U; +} + +fn main() { + let m2 = u32x2([0; 2]); + let m4 = u32x4([0; 4]); + let m8 = u8x8([0; 8]); + let m16 = u8x16([0; 16]); + let m32 = u8x32([0; 32]); + let m64 = u8x64([0; 64]); + + unsafe { + let _: u8 = simd_bitmask(m2); + let _: u8 = simd_bitmask(m4); + let _: u8 = simd_bitmask(m8); + let _: u16 = simd_bitmask(m16); + let _: u32 = simd_bitmask(m32); + let _: u64 = simd_bitmask(m64); + + let _: u16 = simd_bitmask(m2); + //~^ ERROR bitmask `u16`, expected `u8` + + let _: u16 = simd_bitmask(m8); + //~^ ERROR bitmask `u16`, expected `u8` + + let _: u32 = simd_bitmask(m16); + //~^ ERROR bitmask `u32`, expected `u16` + + let _: u64 = simd_bitmask(m32); + //~^ ERROR bitmask `u64`, expected `u32` + + let _: u128 = simd_bitmask(m64); + //~^ ERROR bitmask `u128`, expected `u64` + + } +} diff --git a/src/test/ui/simd/intrinsic/generic-bitmask.stderr b/src/test/ui/simd/intrinsic/generic-bitmask.stderr new file mode 100644 index 00000000000..5aaae68cafb --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-bitmask.stderr @@ -0,0 +1,33 @@ +error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: bitmask `u16`, expected `u8` + --> $DIR/generic-bitmask.rs:53:22 + | +LL | let _: u16 = simd_bitmask(m2); + | ^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: bitmask `u16`, expected `u8` + --> $DIR/generic-bitmask.rs:56:22 + | +LL | let _: u16 = simd_bitmask(m8); + | ^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: bitmask `u32`, expected `u16` + --> $DIR/generic-bitmask.rs:59:22 + | +LL | let _: u32 = simd_bitmask(m16); + | ^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: bitmask `u64`, expected `u32` + --> $DIR/generic-bitmask.rs:62:22 + | +LL | let _: u64 = simd_bitmask(m32); + | ^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: bitmask `u128`, expected `u64` + --> $DIR/generic-bitmask.rs:65:23 + | +LL | let _: u128 = simd_bitmask(m64); + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-cast.rs b/src/test/ui/simd/intrinsic/generic-cast-pass.rs index 15f232e2c0f..15f232e2c0f 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-cast.rs +++ b/src/test/ui/simd/intrinsic/generic-cast-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-cast.rs b/src/test/ui/simd/intrinsic/generic-cast.rs new file mode 100644 index 00000000000..4f4fa06b002 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-cast.rs @@ -0,0 +1,43 @@ +// build-fail + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x8(i32, i32, i32, i32, + i32, i32, i32, i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x4(f32, f32, f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x8(f32, f32, f32, f32, + f32, f32, f32, f32); + + +extern "platform-intrinsic" { + fn simd_cast<T, U>(x: T) -> U; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + + unsafe { + simd_cast::<i32, i32>(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_cast::<i32, i32x4>(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_cast::<i32x4, i32>(x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_cast::<_, i32x8>(x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 + } +} diff --git a/src/test/ui/simd/intrinsic/generic-cast.stderr b/src/test/ui/simd/intrinsic/generic-cast.stderr new file mode 100644 index 00000000000..2226bbbe1bd --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-cast.stderr @@ -0,0 +1,27 @@ +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-cast.rs:34:9 + | +LL | simd_cast::<i32, i32>(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-cast.rs:36:9 + | +LL | simd_cast::<i32, i32x4>(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-cast.rs:38:9 + | +LL | simd_cast::<i32x4, i32>(x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 + --> $DIR/generic-cast.rs:40:9 + | +LL | simd_cast::<_, i32x8>(x); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-comparison.rs b/src/test/ui/simd/intrinsic/generic-comparison-pass.rs index da5c42a1a98..da5c42a1a98 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-comparison.rs +++ b/src/test/ui/simd/intrinsic/generic-comparison-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-comparison.rs b/src/test/ui/simd/intrinsic/generic-comparison.rs new file mode 100644 index 00000000000..3cd38042f0f --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-comparison.rs @@ -0,0 +1,67 @@ +// build-fail + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i16x8(i16, i16, i16, i16, + i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn simd_eq<T, U>(x: T, y: T) -> U; + fn simd_ne<T, U>(x: T, y: T) -> U; + fn simd_lt<T, U>(x: T, y: T) -> U; + fn simd_le<T, U>(x: T, y: T) -> U; + fn simd_gt<T, U>(x: T, y: T) -> U; + fn simd_ge<T, U>(x: T, y: T) -> U; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + + unsafe { + simd_eq::<i32, i32>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_ne::<i32, i32>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_lt::<i32, i32>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_le::<i32, i32>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_gt::<i32, i32>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_ge::<i32, i32>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + simd_eq::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_ne::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_lt::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_le::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_gt::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_ge::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + + simd_eq::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_ne::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_lt::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_le::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_gt::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_ge::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + } +} diff --git a/src/test/ui/simd/intrinsic/generic-comparison.stderr b/src/test/ui/simd/intrinsic/generic-comparison.stderr new file mode 100644 index 00000000000..0eae2688bce --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-comparison.stderr @@ -0,0 +1,111 @@ +error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:28:9 + | +LL | simd_eq::<i32, i32>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:30:9 + | +LL | simd_ne::<i32, i32>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:32:9 + | +LL | simd_lt::<i32, i32>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:34:9 + | +LL | simd_le::<i32, i32>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:36:9 + | +LL | simd_gt::<i32, i32>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:38:9 + | +LL | simd_ge::<i32, i32>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:41:9 + | +LL | simd_eq::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:43:9 + | +LL | simd_ne::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:45:9 + | +LL | simd_lt::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:47:9 + | +LL | simd_le::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:49:9 + | +LL | simd_gt::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/generic-comparison.rs:51:9 + | +LL | simd_ge::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/generic-comparison.rs:54:9 + | +LL | simd_eq::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/generic-comparison.rs:56:9 + | +LL | simd_ne::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/generic-comparison.rs:58:9 + | +LL | simd_lt::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/generic-comparison.rs:60:9 + | +LL | simd_le::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/generic-comparison.rs:62:9 + | +LL | simd_gt::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/generic-comparison.rs:64:9 + | +LL | simd_ge::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 18 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-elements.rs b/src/test/ui/simd/intrinsic/generic-elements-pass.rs index 08544bce45d..08544bce45d 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-elements.rs +++ b/src/test/ui/simd/intrinsic/generic-elements-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-elements.rs b/src/test/ui/simd/intrinsic/generic-elements.rs new file mode 100644 index 00000000000..abde69163bd --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-elements.rs @@ -0,0 +1,77 @@ +// build-fail + +#![feature(repr_simd, platform_intrinsics, rustc_attrs)] + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x2(i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x8(i32, i32, i32, i32, + i32, i32, i32, i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x2(f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x4(f32, f32, f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x8(f32, f32, f32, f32, + f32, f32, f32, f32); + +extern "platform-intrinsic" { + fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; + fn simd_extract<T, E>(x: T, idx: u32) -> E; + + fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U; + fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + + unsafe { + simd_insert(0, 0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_insert(x, 0, 1.0); + //~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64` + simd_extract::<_, f32>(x, 0); + //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32` + + const IDX2: [u32; 2] = [0; 2]; + simd_shuffle2::<i32, i32>(0, 0, IDX2); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + const IDX4: [u32; 4] = [0; 4]; + simd_shuffle4::<i32, i32>(0, 0, IDX4); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + const IDX8: [u32; 8] = [0; 8]; + simd_shuffle8::<i32, i32>(0, 0, IDX8); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + simd_shuffle2::<_, f32x2>(x, x, IDX2); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + simd_shuffle4::<_, f32x4>(x, x, IDX4); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` + simd_shuffle8::<_, f32x8>(x, x, IDX8); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` + + simd_shuffle2::<_, i32x8>(x, x, IDX2); + //~^ ERROR expected return type of length 2, found `i32x8` with length 8 + simd_shuffle4::<_, i32x8>(x, x, IDX4); + //~^ ERROR expected return type of length 4, found `i32x8` with length 8 + simd_shuffle8::<_, i32x2>(x, x, IDX8); + //~^ ERROR expected return type of length 8, found `i32x2` with length 2 + } +} diff --git a/src/test/ui/simd/intrinsic/generic-elements.stderr b/src/test/ui/simd/intrinsic/generic-elements.stderr new file mode 100644 index 00000000000..5b423f7040f --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-elements.stderr @@ -0,0 +1,75 @@ +error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:46:9 + | +LL | simd_insert(0, 0, 0); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` + --> $DIR/generic-elements.rs:48:9 + | +LL | simd_insert(x, 0, 1.0); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` + --> $DIR/generic-elements.rs:50:9 + | +LL | simd_extract::<_, f32>(x, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:54:9 + | +LL | simd_shuffle2::<i32, i32>(0, 0, IDX2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:57:9 + | +LL | simd_shuffle4::<i32, i32>(0, 0, IDX4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:60:9 + | +LL | simd_shuffle8::<i32, i32>(0, 0, IDX8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + --> $DIR/generic-elements.rs:63:9 + | +LL | simd_shuffle2::<_, f32x2>(x, x, IDX2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` + --> $DIR/generic-elements.rs:65:9 + | +LL | simd_shuffle4::<_, f32x4>(x, x, IDX4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` + --> $DIR/generic-elements.rs:67:9 + | +LL | simd_shuffle8::<_, f32x8>(x, x, IDX8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return type of length 2, found `i32x8` with length 8 + --> $DIR/generic-elements.rs:70:9 + | +LL | simd_shuffle2::<_, i32x8>(x, x, IDX2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x8` with length 8 + --> $DIR/generic-elements.rs:72:9 + | +LL | simd_shuffle4::<_, i32x8>(x, x, IDX4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return type of length 8, found `i32x2` with length 2 + --> $DIR/generic-elements.rs:74:9 + | +LL | simd_shuffle8::<_, i32x2>(x, x, IDX8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-gather.rs b/src/test/ui/simd/intrinsic/generic-gather-pass.rs index 805caebe5b1..805caebe5b1 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-gather.rs +++ b/src/test/ui/simd/intrinsic/generic-gather-pass.rs diff --git a/src/test/ui/simd/simd-intrinsic-generic-reduction.rs b/src/test/ui/simd/intrinsic/generic-reduction-pass.rs index 7193fb3527f..4a54afee807 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-reduction.rs +++ b/src/test/ui/simd/intrinsic/generic-reduction-pass.rs @@ -24,15 +24,6 @@ struct f32x4(pub f32, pub f32, pub f32, pub f32); #[derive(Copy, Clone)] struct b8x4(pub i8, pub i8, pub i8, pub i8); -#[repr(simd)] -#[derive(Copy, Clone)] -struct b8x16( - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8 -); - extern "platform-intrinsic" { fn simd_reduce_add_unordered<T, U>(x: T) -> U; fn simd_reduce_mul_unordered<T, U>(x: T) -> U; diff --git a/src/test/ui/simd/intrinsic/generic-reduction.rs b/src/test/ui/simd/intrinsic/generic-reduction.rs new file mode 100644 index 00000000000..ede4b26d19c --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-reduction.rs @@ -0,0 +1,58 @@ +// build-fail +// ignore-emscripten + +// Test that the simd_reduce_{op} intrinsics produce ok-ish error +// messages when misused. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + + +extern "platform-intrinsic" { + fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U; + fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U; + fn simd_reduce_and<T, U>(x: T) -> U; + fn simd_reduce_or<T, U>(x: T) -> U; + fn simd_reduce_xor<T, U>(x: T) -> U; + fn simd_reduce_all<T>(x: T) -> bool; + fn simd_reduce_any<T>(x: T) -> bool; +} + +fn main() { + let x = u32x4(0, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_reduce_add_ordered(z, 0); + //~^ ERROR expected return type `f32` (element of input `f32x4`), found `i32` + simd_reduce_mul_ordered(z, 1); + //~^ ERROR expected return type `f32` (element of input `f32x4`), found `i32` + + let _: f32 = simd_reduce_and(x); + //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` + let _: f32 = simd_reduce_or(x); + //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` + let _: f32 = simd_reduce_xor(x); + //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` + + let _: f32 = simd_reduce_and(z); + //~^ ERROR unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` + let _: f32 = simd_reduce_or(z); + //~^ ERROR unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` + let _: f32 = simd_reduce_xor(z); + //~^ ERROR unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` + + let _: bool = simd_reduce_all(z); + //~^ ERROR unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` + let _: bool = simd_reduce_any(z); + //~^ ERROR unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` + } +} diff --git a/src/test/ui/simd/intrinsic/generic-reduction.stderr b/src/test/ui/simd/intrinsic/generic-reduction.stderr new file mode 100644 index 00000000000..1028faf69a7 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-reduction.stderr @@ -0,0 +1,63 @@ +error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` + --> $DIR/generic-reduction.rs:34:9 + | +LL | simd_reduce_add_ordered(z, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` + --> $DIR/generic-reduction.rs:36:9 + | +LL | simd_reduce_mul_ordered(z, 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` + --> $DIR/generic-reduction.rs:39:22 + | +LL | let _: f32 = simd_reduce_and(x); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` + --> $DIR/generic-reduction.rs:41:22 + | +LL | let _: f32 = simd_reduce_or(x); + | ^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` + --> $DIR/generic-reduction.rs:43:22 + | +LL | let _: f32 = simd_reduce_xor(x); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` + --> $DIR/generic-reduction.rs:46:22 + | +LL | let _: f32 = simd_reduce_and(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` + --> $DIR/generic-reduction.rs:48:22 + | +LL | let _: f32 = simd_reduce_or(z); + | ^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` + --> $DIR/generic-reduction.rs:50:22 + | +LL | let _: f32 = simd_reduce_xor(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_all` intrinsic: unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` + --> $DIR/generic-reduction.rs:53:23 + | +LL | let _: bool = simd_reduce_all(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_any` intrinsic: unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` + --> $DIR/generic-reduction.rs:55:23 + | +LL | let _: bool = simd_reduce_any(z); + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-select.rs b/src/test/ui/simd/intrinsic/generic-select-pass.rs index b850cf9750a..b850cf9750a 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-select.rs +++ b/src/test/ui/simd/intrinsic/generic-select-pass.rs diff --git a/src/test/ui/simd/intrinsic/generic-select.rs b/src/test/ui/simd/intrinsic/generic-select.rs new file mode 100644 index 00000000000..7d68af49e28 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-select.rs @@ -0,0 +1,64 @@ +// build-fail + +// Test that the simd_select intrinsic produces ok-ish error +// messages when misused. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq)] +struct b8x4(pub i8, pub i8, pub i8, pub i8); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq)] +struct b8x8(pub i8, pub i8, pub i8, pub i8, + pub i8, pub i8, pub i8, pub i8); + +extern "platform-intrinsic" { + fn simd_select<T, U>(x: T, a: U, b: U) -> U; + fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; +} + +fn main() { + let m4 = b8x4(0, 0, 0, 0); + let m8 = b8x8(0, 0, 0, 0, 0, 0, 0, 0); + let x = u32x4(0, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_select(m4, x, x); + + simd_select(m8, x, x); + //~^ ERROR mismatched lengths: mask length `8` != other vector length `4` + + simd_select(x, x, x); + //~^ ERROR mask element type is `u32`, expected `i_` + + simd_select(z, z, z); + //~^ ERROR mask element type is `f32`, expected `i_` + + simd_select(m4, 0u32, 1u32); + //~^ ERROR found non-SIMD `u32` + + simd_select_bitmask(0u16, x, x); + //~^ ERROR mask length `16` != other vector length `4` + // + simd_select_bitmask(0u8, 1u32, 2u32); + //~^ ERROR found non-SIMD `u32` + + simd_select_bitmask(0.0f32, x, x); + //~^ ERROR `f32` is not an integral type + + simd_select_bitmask("x", x, x); + //~^ ERROR `&str` is not an integral type + } +} diff --git a/src/test/ui/simd/intrinsic/generic-select.stderr b/src/test/ui/simd/intrinsic/generic-select.stderr new file mode 100644 index 00000000000..c53d581745a --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-select.stderr @@ -0,0 +1,51 @@ +error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched lengths: mask length `8` != other vector length `4` + --> $DIR/generic-select.rs:40:9 + | +LL | simd_select(m8, x, x); + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_` + --> $DIR/generic-select.rs:43:9 + | +LL | simd_select(x, x, x); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_` + --> $DIR/generic-select.rs:46:9 + | +LL | simd_select(z, z, z); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32` + --> $DIR/generic-select.rs:49:9 + | +LL | simd_select(m4, 0u32, 1u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: mismatched lengths: mask length `16` != other vector length `4` + --> $DIR/generic-select.rs:52:9 + | +LL | simd_select_bitmask(0u16, x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32` + --> $DIR/generic-select.rs:55:9 + | +LL | simd_select_bitmask(0u8, 1u32, 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: `f32` is not an integral type + --> $DIR/generic-select.rs:58:9 + | +LL | simd_select_bitmask(0.0f32, x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: `&str` is not an integral type + --> $DIR/generic-select.rs:61:9 + | +LL | simd_select_bitmask("x", x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/intrinsic/generic-shuffle.rs b/src/test/ui/simd/intrinsic/generic-shuffle.rs new file mode 100644 index 00000000000..9611780ac07 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-shuffle.rs @@ -0,0 +1,33 @@ +// build-fail + +// Test that the simd_shuffle intrinsic produces ok-ish error +// messages when misused. + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct Simd<T, const N: usize>([T; N]); + +extern "platform-intrinsic" { + fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; +} + +fn main() { + const I: [u32; 2] = [0; 2]; + const I2: [f32; 2] = [0.; 2]; + let v = Simd::<u32, 4>([0; 4]); + + unsafe { + let _: Simd<u32, 2> = simd_shuffle(v, v, I); + + let _: Simd<u32, 4> = simd_shuffle(v, v, I); + //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic + + let _: Simd<f32, 2> = simd_shuffle(v, v, I); + //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic + + let _: Simd<u32, 2> = simd_shuffle(v, v, I2); + //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic + } +} diff --git a/src/test/ui/simd/intrinsic/generic-shuffle.stderr b/src/test/ui/simd/intrinsic/generic-shuffle.stderr new file mode 100644 index 00000000000..44c57cd7c47 --- /dev/null +++ b/src/test/ui/simd/intrinsic/generic-shuffle.stderr @@ -0,0 +1,21 @@ +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `Simd<u32, 4_usize>` with length 4 + --> $DIR/generic-shuffle.rs:24:31 + | +LL | let _: Simd<u32, 4> = simd_shuffle(v, v, I); + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `u32` (element of input `Simd<u32, 4_usize>`), found `Simd<f32, 2_usize>` with element type `f32` + --> $DIR/generic-shuffle.rs:27:31 + | +LL | let _: Simd<f32, 2> = simd_shuffle(v, v, I); + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: simd_shuffle index must be an array of `u32`, got `[f32; 2]` + --> $DIR/generic-shuffle.rs:30:31 + | +LL | let _: Simd<u32, 2> = simd_shuffle(v, v, I2); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/intrinsic/inlining-issue67557-ice.rs b/src/test/ui/simd/intrinsic/inlining-issue67557-ice.rs new file mode 100644 index 00000000000..7221b3ab769 --- /dev/null +++ b/src/test/ui/simd/intrinsic/inlining-issue67557-ice.rs @@ -0,0 +1,26 @@ +// This used to cause an ICE for an internal index out of range due to simd_shuffle_indices being +// passed the wrong Instance, causing issues with inlining. See #67557. +// +// run-pass +// compile-flags: -Zmir-opt-level=4 +#![feature(platform_intrinsics, repr_simd)] + +extern "platform-intrinsic" { + fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U; +} + +#[repr(simd)] +#[derive(Debug, PartialEq)] +struct Simd2(u8, u8); + +fn main() { + unsafe { + let _: Simd2 = inline_me(); + } +} + +#[inline(always)] +unsafe fn inline_me() -> Simd2 { + const IDX: [u32; 2] = [0, 3]; + simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) +} diff --git a/src/test/ui/simd/intrinsic/inlining-issue67557.rs b/src/test/ui/simd/intrinsic/inlining-issue67557.rs new file mode 100644 index 00000000000..0d15427095a --- /dev/null +++ b/src/test/ui/simd/intrinsic/inlining-issue67557.rs @@ -0,0 +1,42 @@ +// This used to cause assert_10_13 to unexpectingly fail, due to simd_shuffle_indices being passed +// the wrong Instance, causing issues with inlining. See #67557. +// +// run-pass +// compile-flags: -Zmir-opt-level=4 +#![feature(platform_intrinsics, repr_simd)] + +extern "platform-intrinsic" { + fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U; +} + +#[repr(simd)] +#[derive(Debug, PartialEq)] +struct Simd2(u8, u8); + +fn main() { + unsafe { + const IDX: [u32; 2] = [0, 1]; + let p_res: Simd2 = simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX); + let a_res: Simd2 = inline_me(); + + assert_10_11(p_res); + assert_10_13(a_res); + } +} + +#[inline(never)] +fn assert_10_11(x: Simd2) { + assert_eq!(x, Simd2(10, 11)); +} + +#[inline(never)] +fn assert_10_13(x: Simd2) { + assert_eq!(x, Simd2(10, 13)); +} + + +#[inline(always)] +unsafe fn inline_me() -> Simd2 { + const IDX: [u32; 2] = [0, 3]; + simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) +} diff --git a/src/test/ui/simd/intrinsic/issue-85855.rs b/src/test/ui/simd/intrinsic/issue-85855.rs new file mode 100644 index 00000000000..f276fbd6694 --- /dev/null +++ b/src/test/ui/simd/intrinsic/issue-85855.rs @@ -0,0 +1,19 @@ +// Check that appropriate errors are reported if an intrinsic is defined +// with the wrong number of generic lifetime/type/const parameters, and +// that no ICE occurs in these cases. + +#![feature(platform_intrinsics)] +#![crate_type="lib"] + +extern "platform-intrinsic" { + fn simd_saturating_add<'a, T: 'a>(x: T, y: T); + //~^ ERROR: intrinsic has wrong number of lifetime parameters + + fn simd_add<'a, T>(x: T, y: T) -> T; + + fn simd_sub<T, U>(x: T, y: U); + //~^ ERROR: intrinsic has wrong number of type parameters + + fn simd_mul<T, const N: usize>(x: T, y: T); + //~^ ERROR: intrinsic has wrong number of const parameters +} diff --git a/src/test/ui/simd/intrinsic/issue-85855.stderr b/src/test/ui/simd/intrinsic/issue-85855.stderr new file mode 100644 index 00000000000..fb2f1fbc5b1 --- /dev/null +++ b/src/test/ui/simd/intrinsic/issue-85855.stderr @@ -0,0 +1,21 @@ +error[E0094]: intrinsic has wrong number of lifetime parameters: found 1, expected 0 + --> $DIR/issue-85855.rs:9:27 + | +LL | fn simd_saturating_add<'a, T: 'a>(x: T, y: T); + | ^^^^^^^^^^^ expected 0 lifetime parameters + +error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 + --> $DIR/issue-85855.rs:14:16 + | +LL | fn simd_sub<T, U>(x: T, y: U); + | ^^^^^^ expected 1 type parameter + +error[E0094]: intrinsic has wrong number of const parameters: found 1, expected 0 + --> $DIR/issue-85855.rs:17:16 + | +LL | fn simd_mul<T, const N: usize>(x: T, y: T); + | ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0094`. 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 aae6ce4663f..0dee3a0e869 100644 --- a/src/test/ui/simd/shuffle-not-out-of-bounds.rs +++ b/src/test/ui/simd/shuffle-not-out-of-bounds.rs @@ -6,148 +6,42 @@ #[repr(simd)] #[derive(Copy, Clone)] -struct u8x2(u8, u8); +struct u8x2([u8; 2]); #[repr(simd)] #[derive(Copy, Clone)] -struct u8x4(u8, u8, u8, u8); +struct u8x4([u8; 4]); #[repr(simd)] #[derive(Copy, Clone)] -struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); +struct u8x8([u8; 8]); #[repr(simd)] #[derive(Copy, Clone)] -struct u8x16( - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, -); +struct u8x16([u8; 16]); #[repr(simd)] #[derive(Copy, Clone)] -struct u8x32( - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, -); +struct u8x32([u8; 32]); #[repr(simd)] #[derive(Copy, Clone)] -struct u8x64( - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, - u8, -); +struct u8x64([u8; 64]); + +extern "platform-intrinsic" { + pub fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U; + pub fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U; + pub fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U; + pub fn simd_shuffle16<T, U>(x: T, y: T, idx: [u32; 16]) -> U; + pub fn simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U; + pub fn simd_shuffle64<T, U>(x: T, y: T, idx: [u32; 64]) -> U; +} // Test vectors by lane size. Since LLVM does not distinguish between a shuffle // over two f32s and a shuffle over two u64s, or any other such combination, // it is not necessary to test every possible vector, only lane counts. macro_rules! test_shuffle_lanes { - ($n:literal, $x:ident, $y:ident, $t:tt) => { + ($n:literal, $x:ident, $y:ident) => { unsafe { let shuffle: $x = { const ARR: [u32; $n] = { @@ -155,11 +49,10 @@ macro_rules! test_shuffle_lanes { arr[0] = $n * 2; arr }; - extern "platform-intrinsic" { - pub fn $y<T, U>(x: T, y: T, idx: [u32; $n]) -> U; - } - let vec1 = $x$t; - let vec2 = $x$t; + let mut n: u8 = $n; + let vals = [0; $n].map(|_| { n = n - 1; n }); + let vec1 = $x(vals); + let vec2 = $x(vals); $y(vec1, vec2, ARR) }; } @@ -175,24 +68,17 @@ macro_rules! test_shuffle_lanes { // And unfortunately, standard comments, as in the UI test harness, disappear in macros! fn main() { - test_shuffle_lanes!(2, u8x2, simd_shuffle2, (2, 1)); - test_shuffle_lanes!(4, u8x4, simd_shuffle4, (4, 3, 2, 1)); - test_shuffle_lanes!(8, u8x8, simd_shuffle8, (8, 7, 6, 5, 4, 3, 2, 1)); - test_shuffle_lanes!(16, u8x16, simd_shuffle16, - (16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); - test_shuffle_lanes!(32, u8x32, simd_shuffle32, - (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)); - test_shuffle_lanes!(64, u8x64, simd_shuffle64, - (64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, - 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)); + test_shuffle_lanes!(2, u8x2, simd_shuffle2); + test_shuffle_lanes!(4, u8x4, simd_shuffle4); + test_shuffle_lanes!(8, u8x8, simd_shuffle8); + test_shuffle_lanes!(16, u8x16, simd_shuffle16); + test_shuffle_lanes!(32, u8x32, simd_shuffle32); + test_shuffle_lanes!(64, u8x64, simd_shuffle64); extern "platform-intrinsic" { fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; } - let v = u8x2(0, 0); + let v = u8x2([0, 0]); const I: [u32; 2] = [4, 4]; unsafe { let _: u8x2 = simd_shuffle(v, v, I); 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 737fb5e6e51..5492d14f7c9 100644 --- a/src/test/ui/simd/shuffle-not-out-of-bounds.stderr +++ b/src/test/ui/simd/shuffle-not-out-of-bounds.stderr @@ -1,78 +1,71 @@ error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: shuffle index #0 is out of bounds (limit 4) - --> $DIR/shuffle-not-out-of-bounds.rs:163:21 + --> $DIR/shuffle-not-out-of-bounds.rs:56:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(2, u8x2, simd_shuffle2, (2, 1)); - | ---------------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(2, u8x2, simd_shuffle2); + | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: shuffle index #0 is out of bounds (limit 8) - --> $DIR/shuffle-not-out-of-bounds.rs:163:21 + --> $DIR/shuffle-not-out-of-bounds.rs:56:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(4, u8x4, simd_shuffle4, (4, 3, 2, 1)); - | ---------------------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(4, u8x4, simd_shuffle4); + | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: shuffle index #0 is out of bounds (limit 16) - --> $DIR/shuffle-not-out-of-bounds.rs:163:21 + --> $DIR/shuffle-not-out-of-bounds.rs:56:21 | LL | $y(vec1, vec2, ARR) | ^^^^^^^^^^^^^^^^^^^ ... -LL | test_shuffle_lanes!(8, u8x8, simd_shuffle8, (8, 7, 6, 5, 4, 3, 2, 1)); - | ---------------------------------------------------------------------- in this macro invocation +LL | test_shuffle_lanes!(8, u8x8, simd_shuffle8); + | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0511]: invalid monomorphization of `simd_shuffle16` intrinsic: shuffle index #0 is out of bounds (limit 32) - --> $DIR/shuffle-not-out-of-bounds.rs:163:21 + --> $DIR/shuffle-not-out-of-bounds.rs:56:21 | -LL | $y(vec1, vec2, ARR) - | ^^^^^^^^^^^^^^^^^^^ +LL | $y(vec1, vec2, ARR) + | ^^^^^^^^^^^^^^^^^^^ ... -LL | / test_shuffle_lanes!(16, u8x16, simd_shuffle16, -LL | | (16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); - | |_________________________________________________________________- in this macro invocation +LL | test_shuffle_lanes!(16, u8x16, simd_shuffle16); + | ----------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0511]: invalid monomorphization of `simd_shuffle32` intrinsic: shuffle index #0 is out of bounds (limit 64) - --> $DIR/shuffle-not-out-of-bounds.rs:163:21 + --> $DIR/shuffle-not-out-of-bounds.rs:56:21 | -LL | $y(vec1, vec2, ARR) - | ^^^^^^^^^^^^^^^^^^^ +LL | $y(vec1, vec2, ARR) + | ^^^^^^^^^^^^^^^^^^^ ... -LL | / test_shuffle_lanes!(32, u8x32, simd_shuffle32, -LL | | (32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, -LL | | 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); - | |_____________________________________________________________- in this macro invocation +LL | test_shuffle_lanes!(32, u8x32, simd_shuffle32); + | ----------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0511]: invalid monomorphization of `simd_shuffle64` intrinsic: shuffle index #0 is out of bounds (limit 128) - --> $DIR/shuffle-not-out-of-bounds.rs:163:21 + --> $DIR/shuffle-not-out-of-bounds.rs:56:21 | -LL | $y(vec1, vec2, ARR) - | ^^^^^^^^^^^^^^^^^^^ +LL | $y(vec1, vec2, ARR) + | ^^^^^^^^^^^^^^^^^^^ ... -LL | / test_shuffle_lanes!(64, u8x64, simd_shuffle64, -LL | | (64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, -LL | | 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, -LL | | 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, -LL | | 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)); - | |_________________________________________________________________- in this macro invocation +LL | test_shuffle_lanes!(64, u8x64, simd_shuffle64); + | ----------------------------------------------- in this macro invocation | = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) 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 + --> $DIR/shuffle-not-out-of-bounds.rs:84:23 | LL | let _: u8x2 = simd_shuffle(v, v, I); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/simd/simd-size-align.rs b/src/test/ui/simd/size-align.rs index 0afa4947225..0afa4947225 100644 --- a/src/test/ui/simd/simd-size-align.rs +++ b/src/test/ui/simd/size-align.rs diff --git a/src/test/ui/simd/simd-target-feature-mixup.rs b/src/test/ui/simd/target-feature-mixup.rs index 6d7688191b7..6d7688191b7 100644 --- a/src/test/ui/simd/simd-target-feature-mixup.rs +++ b/src/test/ui/simd/target-feature-mixup.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs b/src/test/ui/simd/type-generic-monomorphisation-empty.rs index 0121404c749..0121404c749 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs +++ b/src/test/ui/simd/type-generic-monomorphisation-empty.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr b/src/test/ui/simd/type-generic-monomorphisation-empty.stderr index 00fde199b12..00fde199b12 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr +++ b/src/test/ui/simd/type-generic-monomorphisation-empty.stderr diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-extern-nonnull-ptr.rs b/src/test/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs index ae321c974b9..ae321c974b9 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-extern-nonnull-ptr.rs +++ b/src/test/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-non-primitive.rs b/src/test/ui/simd/type-generic-monomorphisation-non-primitive.rs index 0bc73b15580..0bc73b15580 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-non-primitive.rs +++ b/src/test/ui/simd/type-generic-monomorphisation-non-primitive.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-non-primitive.stderr b/src/test/ui/simd/type-generic-monomorphisation-non-primitive.stderr index 9e8f06b824c..9e8f06b824c 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-non-primitive.stderr +++ b/src/test/ui/simd/type-generic-monomorphisation-non-primitive.stderr diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs b/src/test/ui/simd/type-generic-monomorphisation-oversized.rs index bd0d457b35e..bd0d457b35e 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs +++ b/src/test/ui/simd/type-generic-monomorphisation-oversized.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr b/src/test/ui/simd/type-generic-monomorphisation-oversized.stderr index f4418350115..f4418350115 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr +++ b/src/test/ui/simd/type-generic-monomorphisation-oversized.stderr diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs b/src/test/ui/simd/type-generic-monomorphisation-power-of-two.rs index 9b645d363e9..9b645d363e9 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs +++ b/src/test/ui/simd/type-generic-monomorphisation-power-of-two.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-wide-ptr.rs b/src/test/ui/simd/type-generic-monomorphisation-wide-ptr.rs index 3e02b08ce5d..3e02b08ce5d 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-wide-ptr.rs +++ b/src/test/ui/simd/type-generic-monomorphisation-wide-ptr.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-wide-ptr.stderr b/src/test/ui/simd/type-generic-monomorphisation-wide-ptr.stderr index 3888e7a0f38..3888e7a0f38 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-wide-ptr.stderr +++ b/src/test/ui/simd/type-generic-monomorphisation-wide-ptr.stderr diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation.rs b/src/test/ui/simd/type-generic-monomorphisation.rs index 12f9d65d77a..12f9d65d77a 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation.rs +++ b/src/test/ui/simd/type-generic-monomorphisation.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation.stderr b/src/test/ui/simd/type-generic-monomorphisation.stderr index 7f23893ac85..7f23893ac85 100644 --- a/src/test/ui/simd/simd-type-generic-monomorphisation.stderr +++ b/src/test/ui/simd/type-generic-monomorphisation.stderr diff --git a/src/test/ui/simd/simd-type.rs b/src/test/ui/simd/type-len.rs index d82c70b8d82..d82c70b8d82 100644 --- a/src/test/ui/simd/simd-type.rs +++ b/src/test/ui/simd/type-len.rs diff --git a/src/test/ui/simd/simd-type.stderr b/src/test/ui/simd/type-len.stderr index 4e4a19ea32a..f122d8bb0dc 100644 --- a/src/test/ui/simd/simd-type.stderr +++ b/src/test/ui/simd/type-len.stderr @@ -1,35 +1,35 @@ error[E0075]: SIMD vector cannot be empty - --> $DIR/simd-type.rs:6:1 + --> $DIR/type-len.rs:6:1 | LL | struct empty; | ^^^^^^^^^^^^^ error[E0075]: SIMD vector cannot be empty - --> $DIR/simd-type.rs:9:1 + --> $DIR/type-len.rs:9:1 | LL | struct empty2([f32; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0076]: SIMD vector should be homogeneous - --> $DIR/simd-type.rs:15:1 + --> $DIR/type-len.rs:15:1 | LL | struct i64f64(i64, f64); | ^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type - --> $DIR/simd-type.rs:20:1 + --> $DIR/type-len.rs:20:1 | LL | struct FooV(Foo, Foo); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type - --> $DIR/simd-type.rs:23:1 + --> $DIR/type-len.rs:23:1 | LL | struct FooV2([Foo; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0075]: SIMD vector cannot have more than 32768 elements - --> $DIR/simd-type.rs:26:1 + --> $DIR/type-len.rs:26:1 | LL | struct TooBig([f32; 65536]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/simd/simd-type-wide-ptr.rs b/src/test/ui/simd/type-wide-ptr.rs index 88f62a07ea0..88f62a07ea0 100644 --- a/src/test/ui/simd/simd-type-wide-ptr.rs +++ b/src/test/ui/simd/type-wide-ptr.rs diff --git a/src/test/ui/simd/simd-type-wide-ptr.stderr b/src/test/ui/simd/type-wide-ptr.stderr index 51d3c005072..51d3c005072 100644 --- a/src/test/ui/simd/simd-type-wide-ptr.stderr +++ b/src/test/ui/simd/type-wide-ptr.stderr |
