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

middle-end: Try intermediate types for widening sums

Vectorizer now considers intermediate types for widening sum patterns, improving performance for reductions on AArch64 SVE.

The vectorizer’s widening sum pattern recognition has been improved to consider intermediate integer types, not just the scalar input type. This allows it to utilize target-specific instructions like AArch64 SVE’s VNx2DI <- VNx8HI widening sum, which were previously missed if the input was, for example, VNx8QI. The change enables more efficient code generation for reductions, converting operations that previously required multiple loop iterations into single dot product instructions.

In Details

The vect_recog_widen_sum_pattern function now iterates through wider integer types (up to half the accumulator width) when the exact input type doesn't match a widening sum optab. This is crucial for targets like AArch64 SVE, where direct widening sums from smaller integer types (e.g., qi to di) might not be directly supported by the optab, but intermediate widenings (e.g., qi to hi, then hi to di) are. The change ensures vect_convert_input handles the intermediate conversion, enabling patterns like (short int) byte; patt_1 w+ sum_0; to be recognized. This directly impacts t…

For Context
Optab
Operation table. A data structure within GCC that maps abstract operations (like 'widen_sum') to specific machine instructions or internal functions.
Widen
To increase the data type's width, for example, converting a 16-bit integer to a 32-bit integer. In sums, this refers to accumulating results in a wider type to prevent overflow.
AArch64 SVE
Scalable Vector Extension for ARMv8-A architecture. It provides a flexible vector processing capability.
Vector Reduction
An operation that combines all elements of a vector into a single scalar value, such as summing all elements or finding the maximum.
Dot Product
A vector operation that computes the sum of the products of corresponding elements in two vectors.
Filed Under: vectorizationoptimizationaarch64SVEreduction