GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
i386 Performance Win

i386: Use crc32q for reversed CRC64 with the CRC-32C polynomial

Optimizes CRC64 calculations on 64-bit targets by using the crc32q instruction.

This commit optimizes CRC64 calculations on 64-bit targets by leveraging the crc32q instruction for a specific polynomial (0x1EDC6F4100000000). This replaces a sequence of pclmulqdq and movq instructions with a single crc32q instruction when the input data is XORed with the CRC value. It also corrects an invalid use of the crc32 instruction for SImode CRC with DImode data.

In Details

The i386 backend now uses crc32q to implement a reflected CRC64 calculation when the polynomial is a 32-bit CRC-32C polynomial. This exploits the fact that crc32q with a zero accumulator computes crc32c(data ^ crc). Previously, this would have been expanded using pclmulqdq and movq. This optimization applies only to 64-bit targets supporting TARGET_CRC32.

For Context
CRC64
A 64-bit Cyclic Redundancy Check, a type of error-detecting code used to detect accidental changes to raw data.
CRC-32C
A specific 32-bit CRC polynomial, often used for data integrity checks in storage and networking.
crc32q
An x86 instruction that computes a CRC-32 checksum, often used for hardware-accelerated CRC calculations.
pclmulqdq
An x86 instruction for performing carry-less multiplication of 128-bit operands, often used in cryptographic and CRC calculations.
SImode
GCC's internal representation for single-precision integers, typically 32 bits.
DImode
GCC's internal representation for double-precision integers, typically 64 bits.
Filed Under: i386optimizationCRC