about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgnzlbg <gonzalobg88@gmail.com>2018-05-09 17:09:50 +0200
committergnzlbg <gonzalobg88@gmail.com>2018-05-24 16:04:39 +0200
commit180342df0bbe074a003f797531664ab65b482973 (patch)
treec06e0c85622ef809447190a78e7e3077af395336
parent1ffc30a45976374e914df250e2852821eb811f41 (diff)
downloadrust-180342df0bbe074a003f797531664ab65b482973.tar.gz
rust-180342df0bbe074a003f797531664ab65b482973.zip
add gather/scatter tests for pointers of pointers
-rw-r--r--src/test/run-pass/simd-intrinsic-generic-gather.rs71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/test/run-pass/simd-intrinsic-generic-gather.rs b/src/test/run-pass/simd-intrinsic-generic-gather.rs
index dbc5221441f..54143739a88 100644
--- a/src/test/run-pass/simd-intrinsic-generic-gather.rs
+++ b/src/test/run-pass/simd-intrinsic-generic-gather.rs
@@ -77,4 +77,75 @@ fn main() {
 
         assert_eq!(x, [42., 1., 43., 3., 4., 5., 45., 7.]);
     }
+
+    // test modifying array of *const f32
+    let mut y = [
+        &x[0] as *const f32,
+        &x[1] as *const f32,
+        &x[2] as *const f32,
+        &x[3] as *const f32,
+        &x[4] as *const f32,
+        &x[5] as *const f32,
+        &x[6] as *const f32,
+        &x[7] as *const f32
+    ];
+
+    let default = x4(y[0], y[0], y[0], y[0]);
+    let s_strided = x4(y[0], y[2], y[0], y[6]);
+
+    // reading from *const
+    unsafe {
+        let pointer = &y[0] as *const *const f32;
+        let pointers = x4(
+            pointer.offset(0) as *const *const f32,
+            pointer.offset(2),
+            pointer.offset(4),
+            pointer.offset(6)
+        );
+
+        let r_strided = simd_gather(default, pointers, mask);
+
+        assert_eq!(r_strided, s_strided);
+    }
+
+    // reading from *mut
+    unsafe {
+        let pointer = &mut y[0] as *mut *const f32;
+        let pointers = x4(
+            pointer.offset(0) as *mut *const f32,
+            pointer.offset(2),
+            pointer.offset(4),
+            pointer.offset(6)
+        );
+
+        let r_strided = simd_gather(default, pointers, mask);
+
+        assert_eq!(r_strided, s_strided);
+    }
+
+    // writing to *mut
+    unsafe {
+        let pointer = &mut y[0] as *mut *const f32;
+        let pointers = x4(
+            pointer.offset(0) as *mut *const f32,
+            pointer.offset(2),
+            pointer.offset(4),
+            pointer.offset(6)
+        );
+
+        let values = x4(y[7], y[6], y[5], y[1]);
+        simd_scatter(values, pointers, mask);
+
+        let s = [
+            &x[7] as *const f32,
+            &x[1] as *const f32,
+            &x[6] as *const f32,
+            &x[3] as *const f32,
+            &x[4] as *const f32,
+            &x[5] as *const f32,
+            &x[1] as *const f32,
+            &x[7] as *const f32
+        ];
+        assert_eq!(y, s);
+    }
 }