Skip to content

Commit e517ab9

Browse files
test: add aarch64 CRC32 intrinsic regression test
Covers all 8 LLVM intrinsics (llvm.aarch64.crc32{,c}{b,h,w,x}). Reference values generated with the LLVM backend on aarch64-apple-darwin. Currently fails: cg_clif emits a 'not yet supported' trap.
1 parent 203a324 commit e517ab9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

example/neon.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ use std::mem::transmute;
99
#[cfg(target_arch = "aarch64")]
1010
use std::simd::*;
1111

12+
#[cfg(target_arch = "aarch64")]
13+
#[target_feature(enable = "crc")]
14+
unsafe fn test_crc32() {
15+
assert!(std::arch::is_aarch64_feature_detected!("crc"));
16+
17+
let a: u32 = 42;
18+
let b: u64 = 0xdeadbeef;
19+
20+
assert_eq!(__crc32b(a, b as u8), 0xEB0E363F);
21+
assert_eq!(__crc32h(a, b as u16), 0x9A54BD80);
22+
assert_eq!(__crc32w(a, b as u32), 0xF491F059);
23+
assert_eq!(__crc32d(a, b as u64), 0xD14BBEA6);
24+
25+
assert_eq!(__crc32cb(a, b as u8), 0xF67C32D8);
26+
assert_eq!(__crc32ch(a, b as u16), 0x479108B8);
27+
assert_eq!(__crc32cw(a, b as u32), 0x979F49F8);
28+
assert_eq!(__crc32cd(a, b as u64), 0x0E6BE593);
29+
}
30+
1231
#[cfg(target_arch = "aarch64")]
1332
unsafe fn test_vpmin_s8() {
1433
let a = i8x8::from([1, -2, 3, -4, 5, 6, 7, 8]);
@@ -272,6 +291,8 @@ fn main() {
272291
test_vminq_f32();
273292
test_vaddvq_f32();
274293
test_vrndnq_f32();
294+
295+
test_crc32();
275296
}
276297
}
277298

0 commit comments

Comments
 (0)