]> git.proxmox.com Git - rustc.git/blame - src/stdsimd/coresimd/x86_64/sse42.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / stdsimd / coresimd / x86_64 / sse42.rs
CommitLineData
0531ce1d
XL
1//! `x86_64`'s Streaming SIMD Extensions 4.2 (SSE4.2)
2
3#[cfg(test)]
4use stdsimd_test::assert_instr;
5
6#[allow(improper_ctypes)]
7extern "C" {
8 #[link_name = "llvm.x86.sse42.crc32.64.64"]
9 fn crc32_64_64(crc: u64, v: u64) -> u64;
10}
11
12/// Starting with the initial value in `crc`, return the accumulated
13/// CRC32 value for unsigned 64-bit integer `v`.
83c7162d
XL
14///
15/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_crc32_u64)
0531ce1d
XL
16#[inline]
17#[target_feature(enable = "sse4.2")]
18#[cfg_attr(test, assert_instr(crc32))]
83c7162d 19#[stable(feature = "simd_x86", since = "1.27.0")]
0531ce1d
XL
20pub unsafe fn _mm_crc32_u64(crc: u64, v: u64) -> u64 {
21 crc32_64_64(crc, v)
22}
23
24#[cfg(test)]
25mod tests {
26 use coresimd::arch::x86_64::*;
27
28 use stdsimd_test::simd_test;
29
83c7162d 30 #[simd_test(enable = "sse4.2")]
0531ce1d
XL
31 unsafe fn test_mm_crc32_u64() {
32 let crc = 0x7819dccd3e824;
33 let v = 0x2a22b845fed;
34 let i = _mm_crc32_u64(crc, v);
35 assert_eq!(i, 0xbb6cdc6c);
36 }
37}