Skip to content

Commit bbe6cb3

Browse files
committed
Add alignment parameter to simd_masked_{load,store}
1 parent a2f0023 commit bbe6cb3

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

tests/pass/intrinsics/portable-simd.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -936,25 +936,39 @@ fn simd_float_intrinsics() {
936936
}
937937

938938
fn simd_masked_loadstore() {
939+
use intrinsics::*;
940+
939941
// The buffer is deliberarely too short, so reading the last element would be UB.
940942
let buf = [3i32; 3];
941943
let default = i32x4::splat(0);
942944
let mask = i32x4::from_array([!0, !0, !0, 0]);
943-
let vals = unsafe { intrinsics::simd_masked_load(mask, buf.as_ptr(), default) };
945+
let vals =
946+
unsafe { simd_masked_load::<_, _, _, { SimdAlign::Element }>(mask, buf.as_ptr(), default) };
944947
assert_eq!(vals, i32x4::from_array([3, 3, 3, 0]));
945948
// Also read in a way that the *first* element is OOB.
946949
let mask2 = i32x4::from_array([0, !0, !0, !0]);
947-
let vals =
948-
unsafe { intrinsics::simd_masked_load(mask2, buf.as_ptr().wrapping_sub(1), default) };
950+
let vals = unsafe {
951+
simd_masked_load::<_, _, _, { SimdAlign::Element }>(
952+
mask2,
953+
buf.as_ptr().wrapping_sub(1),
954+
default,
955+
)
956+
};
949957
assert_eq!(vals, i32x4::from_array([0, 3, 3, 3]));
950958

951959
// The buffer is deliberarely too short, so writing the last element would be UB.
952960
let mut buf = [42i32; 3];
953961
let vals = i32x4::from_array([1, 2, 3, 4]);
954-
unsafe { intrinsics::simd_masked_store(mask, buf.as_mut_ptr(), vals) };
962+
unsafe { simd_masked_store::<_, _, _, { SimdAlign::Element }>(mask, buf.as_mut_ptr(), vals) };
955963
assert_eq!(buf, [1, 2, 3]);
956964
// Also write in a way that the *first* element is OOB.
957-
unsafe { intrinsics::simd_masked_store(mask2, buf.as_mut_ptr().wrapping_sub(1), vals) };
965+
unsafe {
966+
simd_masked_store::<_, _, _, { SimdAlign::Element }>(
967+
mask2,
968+
buf.as_mut_ptr().wrapping_sub(1),
969+
vals,
970+
)
971+
};
958972
assert_eq!(buf, [2, 3, 4]);
959973
}
960974

0 commit comments

Comments
 (0)