Skip to content

Commit 5d576f9

Browse files
committed
test x86 crc intrinsics
1 parent e7b6662 commit 5d576f9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

example/std_example.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ fn main() {
122122
#[cfg(target_arch = "x86_64")]
123123
unsafe {
124124
test_simd();
125+
126+
#[cfg(not(jit))]
127+
test_crc32();
125128
}
126129

127130
Box::pin(
@@ -210,6 +213,21 @@ struct I64X2(i64, i64);
210213
#[allow(improper_ctypes_definitions)]
211214
extern "C" fn foo(_a: I64X2) {}
212215

216+
#[cfg(target_arch = "x86_64")]
217+
#[target_feature(enable = "sse4.2")]
218+
#[cfg(not(jit))]
219+
unsafe fn test_crc32() {
220+
assert!(is_x86_feature_detected!("sse4.2"));
221+
222+
let a = 42u32;
223+
let b = 0xdeadbeefu64;
224+
225+
assert_eq!(_mm_crc32_u8(a, b as u8), 4135334616);
226+
assert_eq!(_mm_crc32_u16(a, b as u16), 1200687288);
227+
assert_eq!(_mm_crc32_u32(a, b as u32), 2543798776);
228+
assert_eq!(_mm_crc32_u64(a as u64, b as u64), 241952147);
229+
}
230+
213231
#[cfg(target_arch = "x86_64")]
214232
#[target_feature(enable = "sse2")]
215233
unsafe fn test_simd() {

0 commit comments

Comments
 (0)