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

AArch64 vectorization costs adjusted for scalar-to-vector conversion.

This change improves AArch64 code generation by more accurately costing scalar-to-vector conversions during vectorization, preventing inefficient code.

This commit adjusts the cost model for AArch64 vectorization, specifically addressing scalar-to-vector conversions within vec_construct operations. Previously, the cost of transferring scalar values to SIMD registers was not accurately accounted for, leading to suboptimal vectorization decisions. The corrected cost prevents the compiler from generating inefficient vectorized code sequences in cases where scalar operations would be more performant. This addresses an anti-pattern observed with predicated tails enabled for basic block SLP vectorization.

In Details

This patch modifies vector_costs::add_stmt_cost to account for scalar_to_vec_cost for each element of an external def of kind vec_construct. The patch seeks to prevent suboptimal vectorization of scalar code. This change requires familiarity with the AArch64 backend's cost model, SLP vectorization, and the logic within aarch64_builtin_vectorization. The interaction with store-merging passes is also relevant.

For Context

Compilers use cost models to estimate the performance of different code transformations and pick the most efficient one. Vectorization is a compiler optimization that converts scalar operations (operating on single values) into vector operations (operating on multiple values simultaneously). This commit improves the accuracy of the cost model used by the GCC compiler for AArch64 processors when deciding whether or not to vectorize code. By more accurately accounting for the cost of converting scalar values into vectors, the compiler can make better decisions about when vectorization is beneficial, leading to improved performance.

Filed Under: aarch64vectorizationcost modeloptimization