about summary refs log tree commit diff
path: root/tests/ui/simd/repr_packed.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/simd/repr_packed.rs')
-rw-r--r--tests/ui/simd/repr_packed.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/ui/simd/repr_packed.rs b/tests/ui/simd/repr_packed.rs
index cc54477ae71..f0c6de7c402 100644
--- a/tests/ui/simd/repr_packed.rs
+++ b/tests/ui/simd/repr_packed.rs
@@ -3,15 +3,16 @@
 #![feature(repr_simd, core_intrinsics)]
 #![allow(non_camel_case_types)]
 
-use std::intrinsics::simd::simd_add;
+#[path = "../../auxiliary/minisimd.rs"]
+mod minisimd;
+use minisimd::*;
 
-#[repr(simd, packed)]
-struct Simd<T, const N: usize>([T; N]);
+use std::intrinsics::simd::simd_add;
 
 fn check_size_align<T, const N: usize>() {
     use std::mem;
-    assert_eq!(mem::size_of::<Simd<T, N>>(), mem::size_of::<[T; N]>());
-    assert_eq!(mem::size_of::<Simd<T, N>>() % mem::align_of::<Simd<T, N>>(), 0);
+    assert_eq!(mem::size_of::<PackedSimd<T, N>>(), mem::size_of::<[T; N]>());
+    assert_eq!(mem::size_of::<PackedSimd<T, N>>() % mem::align_of::<PackedSimd<T, N>>(), 0);
 }
 
 fn check_ty<T>() {
@@ -35,14 +36,21 @@ fn main() {
 
     unsafe {
         // powers-of-two have no padding and have the same layout as #[repr(simd)]
-        let x: Simd<f64, 4> =
-            simd_add(Simd::<f64, 4>([0., 1., 2., 3.]), Simd::<f64, 4>([2., 2., 2., 2.]));
-        assert_eq!(std::mem::transmute::<_, [f64; 4]>(x), [2., 3., 4., 5.]);
+        let x: PackedSimd<f64, 4> =
+            simd_add(
+                PackedSimd::<f64, 4>([0., 1., 2., 3.]),
+                PackedSimd::<f64, 4>([2., 2., 2., 2.]),
+            );
+        assert_eq!(x.into_array(), [2., 3., 4., 5.]);
 
         // non-powers-of-two should have padding (which is removed by #[repr(packed)]),
         // but the intrinsic handles it
-        let x: Simd<f64, 3> = simd_add(Simd::<f64, 3>([0., 1., 2.]), Simd::<f64, 3>([2., 2., 2.]));
-        let arr: [f64; 3] = x.0;
+        let x: PackedSimd<f64, 3> =
+            simd_add(
+                PackedSimd::<f64, 3>([0., 1., 2.]),
+                PackedSimd::<f64, 3>([2., 2., 2.]),
+            );
+        let arr: [f64; 3] = x.into_array();
         assert_eq!(arr, [2., 3., 4.]);
     }
 }