test x86 crc intrinsics

This commit is contained in:
Folkert 2024-05-11 21:49:59 +02:00
parent e7b6662464
commit 9059a74fd0
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C

View File

@ -210,6 +210,21 @@ fn rust_call_abi() {
#[allow(improper_ctypes_definitions)]
extern "C" fn foo(_a: I64X2) {}
#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "sse4.2")]
#[cfg(not(jit))]
unsafe fn test_crc32() {
assert!(is_x86_feature_detected!("sse4.2"));
let a = 42u32;
let b = 0xdeadbeefu64;
assert_eq!(_mm_crc32_u8(a, b as u8), 4135334616);
assert_eq!(_mm_crc32_u16(a, b as u16), 1200687288);
assert_eq!(_mm_crc32_u32(a, b as u32), 2543798776);
assert_eq!(_mm_crc32_u64(a as u64, b as u64), 241952147);
}
#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "sse2")]
unsafe fn test_simd() {
@ -248,6 +263,9 @@ unsafe fn test_simd() {
#[rustfmt::skip]
let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)));
assert_eq!(mask1, 1);
#[cfg(not(jit))]
test_crc32();
}
#[cfg(target_arch = "x86_64")]