Skip to content

Commit d0dc36e

Browse files
committed
Add tests
1 parent eb4720d commit d0dc36e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// We're testing aarch64 target specific features
2+
//@only-target: aarch64
3+
//@compile-flags: -C target-feature=+neon
4+
5+
use std::arch::aarch64::*;
6+
use std::arch::is_aarch64_feature_detected;
7+
8+
fn main() {
9+
assert!(is_aarch64_feature_detected!("neon"));
10+
11+
unsafe {
12+
test_neon();
13+
}
14+
}
15+
16+
#[target_feature(enable = "neon")]
17+
unsafe fn test_neon() {
18+
// Adapted from library/stdarch/crates/core_arch/src/aarch64/neon/mod.rs
19+
unsafe fn test_vpmaxq_u8() {
20+
let a = vld1q_u8([1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8].as_ptr());
21+
let b = vld1q_u8([0, 3, 2, 5, 4, 7, 6, 9, 0, 3, 2, 5, 4, 7, 6, 9].as_ptr());
22+
let e = [2, 4, 6, 8, 2, 4, 6, 8, 3, 5, 7, 9, 3, 5, 7, 9];
23+
let mut r = [0; 16];
24+
vst1q_u8(r.as_mut_ptr(), vpmaxq_u8(a, b));
25+
assert_eq!(r, e);
26+
}
27+
test_vpmaxq_u8();
28+
29+
unsafe fn test_vpmaxq_u8_is_unsigned() {
30+
let a = vld1q_u8(
31+
[255, 0, 253, 252, 251, 250, 249, 248, 255, 254, 253, 252, 251, 250, 249, 248].as_ptr(),
32+
);
33+
let b = vld1q_u8([254, 3, 2, 5, 4, 7, 6, 9, 0, 3, 2, 5, 4, 7, 6, 9].as_ptr());
34+
let e = [255, 253, 251, 249, 255, 253, 251, 249, 254, 5, 7, 9, 3, 5, 7, 9];
35+
let mut r = [0; 16];
36+
vst1q_u8(r.as_mut_ptr(), vpmaxq_u8(a, b));
37+
assert_eq!(r, e);
38+
}
39+
test_vpmaxq_u8_is_unsigned();
40+
}

0 commit comments

Comments
 (0)