about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-11-20 01:09:41 +0100
committerGitHub <noreply@github.com>2021-11-20 01:09:41 +0100
commitcf69f9e2206c708cb0c4535cab9e7a64c23add06 (patch)
tree6ac00c06b0824c37dc2b3e673d764ab5468df9ba /src/test
parent5c98cf145dc6e71a33f4c20b64a9d8eeeaf8b1b3 (diff)
parent0304e16f3b357c3df48b25277127c658b5169fd4 (diff)
downloadrust-cf69f9e2206c708cb0c4535cab9e7a64c23add06.tar.gz
rust-cf69f9e2206c708cb0c4535cab9e7a64c23add06.zip
Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obk
fix CTFE/Miri simd_insert/extract on array-style repr(simd) types

The changed test would previously fail since `place_index` would just return the only field of `f32x4`, i.e., the array -- rather than *indexing into* the array which is what we have to do.

The new helper methods will also be needed for https://github.com/rust-lang/miri/issues/1912.

r? ``````@oli-obk``````
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/consts/const-eval/simd/insert_extract.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/test/ui/consts/const-eval/simd/insert_extract.rs b/src/test/ui/consts/const-eval/simd/insert_extract.rs
index cae8fcf1068..a1d6c5e51b4 100644
--- a/src/test/ui/consts/const-eval/simd/insert_extract.rs
+++ b/src/test/ui/consts/const-eval/simd/insert_extract.rs
@@ -7,7 +7,9 @@
 
 #[repr(simd)] struct i8x1(i8);
 #[repr(simd)] struct u16x2(u16, u16);
-#[repr(simd)] struct f32x4(f32, f32, f32, f32);
+// Make some of them array types to ensure those also work.
+#[repr(simd)] struct i8x1_arr([i8; 1]);
+#[repr(simd)] struct f32x4([f32; 4]);
 
 extern "platform-intrinsic" {
     #[rustc_const_stable(feature = "foo", since = "1.3.37")]
@@ -26,6 +28,14 @@ fn main() {
         assert_eq!(Y0, 42);
     }
     {
+        const U: i8x1_arr = i8x1_arr([13]);
+        const V: i8x1_arr = unsafe { simd_insert(U, 0_u32, 42_i8) };
+        const X0: i8 = V.0[0];
+        const Y0: i8 = unsafe { simd_extract(V, 0) };
+        assert_eq!(X0, 42);
+        assert_eq!(Y0, 42);
+    }
+    {
         const U: u16x2 = u16x2(13, 14);
         const V: u16x2 = unsafe { simd_insert(U, 1_u32, 42_u16) };
         const X0: u16 = V.0;
@@ -38,12 +48,12 @@ fn main() {
         assert_eq!(Y1, 42);
     }
     {
-        const U: f32x4 = f32x4(13., 14., 15., 16.);
+        const U: f32x4 = f32x4([13., 14., 15., 16.]);
         const V: f32x4 = unsafe { simd_insert(U, 1_u32, 42_f32) };
-        const X0: f32 = V.0;
-        const X1: f32 = V.1;
-        const X2: f32 = V.2;
-        const X3: f32 = V.3;
+        const X0: f32 = V.0[0];
+        const X1: f32 = V.0[1];
+        const X2: f32 = V.0[2];
+        const X3: f32 = V.0[3];
         const Y0: f32 = unsafe { simd_extract(V, 0) };
         const Y1: f32 = unsafe { simd_extract(V, 1) };
         const Y2: f32 = unsafe { simd_extract(V, 2) };