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

aarch64: Implement bitcompress and bitexpand optabs for SVE2

AArch64 GCC now supports __builtin_bitcompress and __builtin_bitexpand using SVE2 instructions.

This commit introduces support for the __builtin_bitcompress and __builtin_bitexpand intrinsics on AArch64, leveraging SVE2’s BEXT and BDEP instructions. These operations, which perform parallel bit extract and deposit, were previously expanded to less efficient loops or sequences of shifts. The implementation extends existing patterns to scalar modes and utilizes SIMD&FP registers, with the compiler handling register movement and vector element selection.

In Details

This change adds optab expanders for SImode and DImode for the bitcompress and bitexpand operations, targeting the TARGET_SVE_BITPERM feature. It extends the existing BDEP/BEXT/BGRP patterns to scalar types by using SVE registers and fmov for operand transfer. The effective-target check aarch64_sve2_bitperm_hw is added for runtime tests. This allows efficient use of the SVE2 bit permutation instructions on scalar types.

For Context
optabs
Optimization tables that map compiler intermediate representation (IR) operations to specific machine instructions or sequences.
SVE2
Scalable Vector Extension 2, an optional extension to the Arm architecture that provides advanced vector processing capabilities.
FEAT_SVE_BitPerm
A specific feature of SVE2 that enables bit manipulation instructions like BEXT (bit extract) and BDEP (bit deposit).
SImode
GCC's internal representation for a single integer machine word (typically 32 bits).
DImode
GCC's internal representation for a double-precision integer machine word (typically 64 bits).
vector elements
Individual data items within a larger vector register, processed in parallel by SIMD or vector instructions.
+ssve-bitperm
A compiler flag or target feature indicating support for SVE2 bit permutation instructions in streaming mode.
Filed Under: aarch64SVE2intrinsicsoptimization