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

AArch64: Improve vectorizer's costing of truncated stores.

Vectorizer now correctly costs truncated stores on AArch64, preventing incorrect vectorization of scalar code.

This commit enhances the AArch64 vectorizer’s accuracy by improving the costing of truncated stores. Previously, the vectorizer overestimated costs for scalar assignments that were effectively free as part of a store operation, potentially leading to incorrect vectorization. A new function, vect_is_truncating_store, is introduced to identify these cases, ensuring that code with truncating stores is not mis-vectorized.

In Details

The AArch64 vectorizer's cost model previously overcharged scalar narrowing conversions that were part of stores, particularly impacting code like dst[i] = (unsigned char) src[i]. This could lead to incorrect vectorization decisions. The change introduces vect_is_truncating_store by analogy with vect_is_extending_load in config/aarch64/aarch64.cc. This function helps the vectorizer (aarch64_sve_adjust_stmt_cost) to assign a cost of 0 to such statements, preventing erroneous vectorization, especially for predicated tails in SLP.

For Context
vectorizer
A component of a compiler that automatically transforms scalar code into equivalent vector code, enabling parallel execution on multiple data elements simultaneously.
truncated store
A memory write operation where the data being written is narrower than the target memory location's natural width, implying a loss of information or a conversion. For example, storing a byte into a 32-bit word.
SLP
Sliding-window Pattern. A vectorization technique that identifies and groups similar scalar operations that can be executed in parallel on vector registers.
AArch64
The 64-bit ARM architecture, commonly used in mobile devices and increasingly in servers and personal computers.
Filed Under: aarch64vectorizationperformancecompiler optimization