GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Add __builtin_bitreverse128 intrinsic.

Introduces the `__builtin_bitreverse128` intrinsic for reversing the bit order of 128-bit integers.

This commit adds a new builtin function, __builtin_bitreverse128, to GCC. This function reverses the order of bits within a 128-bit integer. Having this builtin allows the compiler to generate optimized code for bit reversal on 128-bit values, which is useful in some specialized algorithms.

In Details

This commit introduces __builtin_bitreverse128 to builtins.def, and handles it in expand_builtin, is_inexpensive_builtin, fold-const-call.cc, fold-const.cc, tree-ssa-ccp.cc, and tree-ssa-phiopt.cc. This change mirrors the existing __builtin_bswap128 and provides a similar functionality for bit reversal. Toolchain devs should note the handling in various optimization passes.

For Context

Builtin functions are special functions recognized directly by the compiler. This commit adds a new builtin that reverses the order of bits in a 128-bit integer. Bit reversal is a common operation in certain algorithms, such as fast Fourier transforms and cryptography. By providing a builtin, the compiler can generate highly optimized code for this operation, potentially leading to significant performance gains.

Filed Under: builtinbitreverseoptimization