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

aarch64: Add const folding for crc32 intrinsics

Enables constant folding for aarch64 CRC32 intrinsics.

This commit introduces constant folding capabilities for the ARMv8-A CRC32 intrinsics (__crc32 and __crc32c) on the aarch64 architecture. Similar to the existing x86 implementation, it uses calculate_reversed_crc with the appropriate polynomial to precompute results for constant arguments. New test cases are included to verify the correctness of this folding.

In Details

The aarch64_general_fold_builtin function in config/aarch64/aarch64-builtins.cc now handles constant folding for __crc32 and __crc32c intrinsics. This is achieved by invoking calculate_reversed_crc with the specific CRC32 polynomial used by these instructions. This optimization allows the compiler to precompute the results of these intrinsics when their arguments are compile-time constants, similar to the established pattern for x86 CRC32 instructions. Test cases crc32-const-fold.c and crc32c-const-fold.c have been added to validate this functionality.

For Context
const folding
A compiler optimization technique where expressions with constant operands are evaluated at compile time rather than runtime. This can improve performance by reducing runtime computation.
aarch64
The 64-bit ARM architecture, widely used in mobile devices, servers, and embedded systems.
intrinsics
Special functions or instructions that allow programmers to access hardware-specific operations or low-level features directly from high-level code, often providing performance benefits.
CRC32
Cyclic Redundancy Check. A type of checksum algorithm used for detecting errors in data transmission or storage. CRC32 uses a 32-bit polynomial.
Filed Under: aarch64optimizationintrinsicsconst folding