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

i386: Add AVX512BMM bitreverse lowering

Improves i386 bitreverse instruction generation by utilizing AVX512-BMM instructions when available.

This commit introduces a new lowering path for the bitreverse operation on i386 architectures, leveraging the vbitrevb instruction from the AVX512-BMM extension when AVX512VL is also present. This provides a more efficient implementation compared to the previous fallback using GFNI instructions. The change includes updates to the machine description files and adds test cases to verify both the new AVX512-BMM path and the GFNI fallback.

In Details

This patch adds a new instruction pattern for bitreverse in config/i386/i386.md that requires AVX512VL and AVX512BMM. The ix86_expand_bitreverse function in i386-expand.cc is modified to use vbitrevb when these features are available, otherwise falling back to GFNI. A new optab VI_AVX512VL is used in sse.md for the vector version. This optimizes scalar bitreversal operations by using dedicated hardware instructions when supported, improving performance for bit manipulation tasks.

For Context
AVX512-BMM
Advanced Vector Extensions 512-bit Bit Manipulation instructions, a set of SIMD instructions for performing complex bitwise operations efficiently on 512-bit registers.
AVX512VL
Advanced Vector Extensions 512-bit Vector Length extensions, which allow AVX-512 instructions to operate on 128-bit and 256-bit registers, providing more flexibility.
GFNI
Galois Field New Instructions, a set of Intel instructions designed to accelerate cryptography and error correction codes, which can also be used for certain bit manipulation tasks.
lowering
The process in a compiler where high-level intermediate representation (IR) constructs are transformed into lower-level, more machine-specific instructions.
optab
Operation table. A data structure in GCC that maps generic GCC operations (like addition, bitwise operations) to specific machine instructions for a given target architecture.
Filed Under: i386AVX512optimizationcompiler