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

aarch64: Use SVE ASRD for vector division by powers of two

Optimizes aarch64 vector division by powers of two using SVE ASRD instruction instead of SDIV.

This patch enables the use of the SVE ASRD instruction for vector division by a constant power of two on aarch64 targets. Previously, such operations would use the general SVE SDIV instruction, but ASRD (Arithmetic Shift Right, rounds towards zero) is more efficient for this specific case, leading to improved performance.

In Details

The aarch64 backend's instruction selection in config/aarch64/aarch64.cc now uses aarch64_try_sdiv_pow2 to rewrite TRUNC_DIV_EXPR with a positive power-of-two constant divisor. This allows the vectorizer to leverage the SVE ASRD instruction via the sdiv_pow2 optab, replacing a more general SDIV operation for improved performance.

For Context
SVE
Scalable Vector Extension, an advanced SIMD instruction set for ARM processors that allows vector lengths to vary.
ASRD
A SVE instruction that performs an arithmetic shift right, effectively dividing by a power of two. It rounds towards zero.
SDIV
The general SVE instruction for signed integer division.
optab
A table within GCC that maps abstract operations to specific machine instructions or patterns.
TRUNC_DIV_EXPR
An intermediate representation (IR) node in GCC representing a division operation where the result is truncated.
Filed Under: aarch64optimizationSVE