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

RISC-V: Enable clmulr for reversed crc64 on rv64.

RISC-V compiler now uses `clmulr` for reversed CRC64 calculations on rv64, improving efficiency.

This commit enables the use of the clmulr instruction for reversed CRC64 calculations on the RISC-V rv64 architecture. Previously, a guard prevented this optimization on rv64. The change adapts the quotient calculation to handle 65-bit values correctly, ensuring that the clmulr instruction’s output is accurate for CRC64 operations. New tests are added to verify this functionality.

In Details

This patch removes the 64-bit guard in config/riscv/bitmanip.md and config/riscv/riscv.cc that prevented the clmulr pattern for reversed CRC64 from being used on rv64. The quotient calculation in expand_reversed_crc_using_clmul is adjusted for 65-bit inputs, and new tests are added for rv64 variants. This enables more efficient CRC64 computations on the target architecture by leveraging the clmulr instruction.

For Context
clmulr
A RISC-V instruction that performs a carry-less multiplication, often used for Galois Field arithmetic such as CRC calculations.
rv64
A 64-bit variant of the RISC-V instruction set architecture.
CRC64
Cyclic Redundancy Check with a 64-bit checksum. Used for error detection in data transmission and storage.
reversed crc
A variant of CRC calculation where the bit order of the input data and the polynomial is reversed. This can sometimes be more efficient on certain architectures.
Filed Under: risc-voptimizationcrc