Instruction
CRC32
Accumulates a CRC-32C checksum (Castagnoli polynomial) over a 1-, 2-, 4- or 8-byte operand.
CRC32 folds 1, 2, 4 or 8 bytes of data into a running 32-bit checksum. Despite the name, the checksum is CRC-32C, with Castagnoli’s polynomial 0x1EDC6F41, not the CRC-32 whose polynomial is 0x04C11DB7: a format that uses the latter gains nothing from this instruction and needs another method, such as carry-less multiplication with PCLMULQDQ.
What it leaves to the program
The instruction does the polynomial division and nothing else.
CRC-32C as formats define it starts from all ones and inverts the
final value, so code does both around its loop: crc = ~crc, one
CRC32 per chunk of data, then ~crc. With them, the nine bytes
“123456789” give 0xE3069283; without them, 0x58E3FA20.
The CRC lives in bits 31:0 of the destination. The 64-bit form reads 8
bytes per step, but its result is still 32 bits wide with bits 63:32
cleared, and the upper half of the incoming register does not count: Zen
5 gave 9F787F65H, the result from FFFFFFFFH, for the bytes “12345678”
whether RCX held 32206E22FFFFFFFFH or BD8D94DAFFFFFFFFH. So
_mm_crc32_u64 returns a 64-bit value whose upper half is zero, and a
loop can feed it back as it is.
The data enters bit 0 first, and the CRC’s coefficients are stored in reverse, which is why the page’s pseudocode shifts right and uses 0x82F63B78, the polynomial with its bits reversed. AMD’s manual calls this reversal “inverting” the operands and the result; it means the order of the bits, not their values, and Zen 5’s results agree.
Compilers
GCC 14 and Clang 23 at -O2 never turn a bitwise CRC-32C loop into
CRC32, even with -msse4.2; Clang replaces the inner loop by a
256-entry table instead. The intrinsics are the way to the
instruction: _mm_crc32_u8 in a byte loop becomes
crc32 eax, byte ptr [rsi], which Clang unrolls eight times.
Speed
Intel’s optimization manual uses CRC32 as a string hash and finds it about twice as fast as a multiply-and-add hash for short and medium strings (Section 14.1.1). In Zen 5, three of the six integer ALUs can compute CRCs (AMD’s Zen 5 guide, Section 2.10.2), and the guide’s instruction table lists CRC32 as one macro-op with a latency of three cycles.
CRC32 belongs to SSE4.2 and so to x86-64-v2; APX adds an EVEX form that reaches its new registers.
In the optimization guide
What the optimization guide says about CRC32, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Golden Cove and Raptor Cove
- Integer execution: Port 1 alone runs the slower integer operations: multiplication, PDEP and PEXT,
popcnt,bsr,crc32and the double shifts with an immediate count, which LLVM’s models give a latency of three cycles and one per cycle.
Silvermont to Goldmont Plus
- Out-of-order and in-order execution: On Silvermont shifts and rotates run on integer port 0, and jumps, multiplication,
popcnt,crc32and bit operations on port 1. sources differ - Instruction set and counters: Silvermont is the first Atom core with SSE4.2 and POPCNT; Goldmont Plus adds RDPID and PTWRITE.
Tremont
- Integer execution: Three ALU ports run simple integer operations, three a cycle; shifts go to port 00 only, and multiplication, division,
popcnt,crc32and the bit operations to port 01 only.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
CRC32 r32/64, m8
CRC32_GPRyy_MEMb | F2 0F 38 F0 /r | SSE4.2 |
CRC32 r32/64, r8
CRC32_GPRyy_GPR8b | F2 0F 38 F0 /r | SSE4.2 |
CRC32 r32/64, m16/32/64
CRC32_GPRyy_MEMv | F2 0F 38 F1 /r | SSE4.2 |
CRC32 r32/64, r16/32/64
CRC32_GPRyy_GPRv | F2 0F 38 F1 /r | SSE4.2 |
CRC32 r32/64, r8
CRC32_GPRy_GPR8i8_APX | EVEX.LLZ.NP.MAP4.SCALABLE F0 /r | APX_F |
CRC32 r32/64, m8
CRC32_GPRy_MEMi8_APX | EVEX.LLZ.NP.MAP4.SCALABLE F0 /r | APX_F |
CRC32 r32/64, r16/32/64
CRC32_GPRy_GPRv_APX | EVEX.LLZ.NP.MAP4.SCALABLE F1 /r | APX_F |
CRC32 r32/64, m16/32/64
CRC32_GPRy_MEMv_APX | EVEX.LLZ.NP.MAP4.SCALABLE F1 /r | APX_F |
Latency and throughput
| Model | r32, m8r64, m8r32, m16r32, m32r64, m64 | r32, r8r64, r8 | r32, r16 | r32, r32 | r64, r64 |
|---|---|---|---|---|---|
| Sandy Bridge, Haswell, Broadwell, Skylake, Skylake-SP, Ice Lake, Alder Lake, Sapphire Rapids | 8 / 1p1 | 3 / 1p1 | 3 / 1p1 | 3 / 1p1 | 3 / 1p1 |
| Lunar Lake | 7 / 1.33p135 | 3 / 1p135 | 3 / 1p135 | 3 / 1p135 | 3 / 1p135 |
| Silvermont | 6 / 1IEC1 MEC | 3 / 1IEC1 | 3 / 1IEC1 | 3 / 1IEC1 | 3 / 1IEC1 |
| Piledriver | 6 / 2EX0 EX1 | 2 / 2EX0 EX1 | 5 / 5EX0 EX1 | 6 / 6EX0 EX1 | 10 / 8.5EX0 EX1 |
| Zen, Zen 2 | 10 / 1FPU0 | 3 / 1FPU0 | 3 / 1FPU0 | 3 / 1FPU0 | 3 / 1FPU0 |
| Zen 3, Zen 4 | 7 / 1ALU1 | 3 / 1ALU1 | 3 / 1ALU1 | 3 / 1ALU1 | 3 / 1ALU1 |
| Jaguar | 6 / 2ALU0 ALU1 | 3 / 2ALU0 ALU1 | 3 / 2ALU0 ALU1 | 3 / 2ALU0 ALU1 | 3 / 2ALU0 ALU1 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
crc = dest & 0xFFFFFFFF # the CRC so far: bits 31:0, even of r64
crc ^= src.read() # the data enters bit 0 first
for i in range(src.bits):
if crc & 1:
crc = crc >> 1 ^ 0x82F63B78 # Castagnoli's polynomial 1EDC6F41
else: # with its bits reversed
crc >>= 1
dest.write(crc) # bits 63:32 cleared, even of r64
# no inversion before or after: CRC-32C as software computes it
# starts from all ones and inverts the resultRun on AMD Zen 5 (EPYC 9645): 70 cases. The APX forms were not run: none of these processors has APX.
Operands
| Operand | Kind | Action |
|---|---|---|
CRC32 r32/64, r/m8 CRC32 r32/64, r/m16/32/64 | ||
r32/64 | explicit | read, write |
r/m8/16/32/64 | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- Legacy forms
- none in XED
- EVEX forms
APX-EVEX-INT
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to CRC32, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
__crc32b
unsigned int __crc32b(unsigned int __C, unsigned char __D) |
|
__crc32d
unsigned int __crc32d(unsigned int __C, unsigned int __D) |
|
__crc32q
unsigned long long __crc32q(unsigned long long __C, unsigned long long __D) |
|
__crc32w
unsigned int __crc32w(unsigned int __C, unsigned short __D) |
|
_mm_crc32_u16
unsigned int _mm_crc32_u16(unsigned int __C, unsigned short __D) |
|
_mm_crc32_u32
unsigned int _mm_crc32_u32(unsigned int __C, unsigned int __D) |
|
_mm_crc32_u64
unsigned long long _mm_crc32_u64(unsigned long long __C, unsigned long long __D) |
|
_mm_crc32_u8
unsigned int _mm_crc32_u8(unsigned int __C, unsigned char __D) |
|
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
SSE42 | SSE4.2 | Nehalem, Westmere, Sandy Bridge, Ivy Bridge, Haswell, Broadwell, Skylake, Comet Lake, Cannon Lake, Ice Lake (client), Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Skylake-SP, Cascade Lake, Cooper Lake, Ice Lake (server), Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Silvermont, Goldmont, Goldmont Plus, Tremont, Snow Ridge, Lakefield, Sierra Forest, Clearwater Forest, Knights Landing, Knights Mill, K10 (Family 10h), Bulldozer, Piledriver, Zen, Zen+, Zen 2, Zen 3, Zen 4, Zen 5, Zen 6 Note: XED's AMD_K10 inherits everything from its Westmere chip, including SSSE3, SSE4.1, SSE4.2, AES-NI and PCLMULQDQ; GCC's -march=amdfam10 has none of them. |
APX_F | APX_F | Nova Lake, Diamond Rapids |
More SSE4.2 instructions
More APX instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-205 (CRC32)
- Intel Advanced Performance Extensions (Intel APX) Architecture Specification, revision 9.0 (355828-009, August 2026)
- AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.39, October 2026)
- Intel 64 and IA-32 Architectures Optimization Reference Manual, Volume 1 (248966-051, October 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The intrinsics and their signatures come from Clang and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.