This topic has not yet been rated - Rate this topic

_mm_crc32_u64

Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction crc32. This instruction adds one parameter to the CRC-32C checksum of the other parameter.

unsigned int64 _mm_crc32_u64 (
   unsigned __int64 crc,
   unsigned __int64 v
); 

Parameter

Description

[in] crc

An unsigned 64-bit integer to add.

[in] v

A 64-bit integer. The checksum will be computed from this input parameter.

r := crc + CRC-32C(v)

Intrinsic

Architecture

_mm_crc32_u64

x64

Header file <nmmintrin.h>

CRC32-C algorithm is based on polynomial 0x1EDC6F41. It is implemented by following little-endian convention. This means that the most significant bit is treated as the least significant bit in the quotient.

Before you use this intrinsic, software must ensure that the processor supports this instruction.

#include <stdio.h>
#include <nmmintrin.h>

int main ()
{
    unsigned __int64 crc = 0x000011115555AAAA;
    unsigned __int64 input = 0x88889999EEEE3333;

    unsigned __int64 res = _mm_crc32_u64(crc, input);
    printf_s("Result res: 0x%08X%08X\n", (unsigned int) (res>>32), res);

    return 0;
}
Result res: 0x0000000016F57621
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
crc parameter and result are only 32-bit values
The 64 bit variety of the CRC32 instruction performs two separate CRC32 operations on the low and high 32 bits of the source data, respectively; and produces a single 32 bit result. Only 32 bits are effective for both the crc parameter and the return value, thus in the example : $0$0 $0 $0unsigned __int64 crc = 0x000011115555AAAA;$0 $0$0 $0 $0The actual value as used by the crc32 instruction is 0x5555AAAA, with the upper 0x00001111 disregarded.  Furthermore, you can display the result simply by discarding the upper 32 bits (which will always be zero);$0 $0$0 $0 $0printf_s("Result res: 0x%08X\n", (unsigned int) res);$0
Printf parameters
Instead of
printf_s("Result res: 0x%08X%08X\n", (unsigned int) (res>>32), res);
you could do
printf_s("Result res: 0x%016I64X\n", res);
or
printf_s("Result res: 0x%016llX\n", res);