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

Fold reductions of vector duplicates and repeats [PR127039]

Optimizes vector reductions by folding idempotent operations on duplicate vectors.

This commit enables GCC to fold vector reductions like REDUC_MAX, REDUC_MIN, REDUC_AND, and REDUC_IOR when applied to duplicate vectors. For example, a REDUC_MAX of a vector [x, x, x] now simplifies to x. It also handles XOR reductions on duplicate vectors, folding them to zero if the lane count is provably even, and correctly processes scalable vectors.

In Details

Enhances match.pd and fold_const_reduction to handle idempotent vector reductions on duplicate or repeating vector constants. This includes folding REDUC_MAX/MIN/AND/IOR of VEC_DUPLICATE_EXPR to the duplicated element, and REDUC_XOR to zero for even lane counts. It handles both fixed-length and scalable vectors, and considers NaN propagation for floating-point reductions.

For Context
REDUC_MAX/MIN/AND/IOR
Vector reduction operations that compute the maximum, minimum, bitwise AND, or bitwise OR across all lanes of a vector.
VEC_DUPLICATE_EXPR
An expression that represents a vector where all elements are copies of a single scalar value.
match.pd
A pattern matching file used by GCC for optimizing instruction selection, particularly for vector operations.
SVE
Scalable Vector Extension, an ARM architecture extension providing vector processing capabilities with a vector length that can vary at runtime.
NaN propagation
The behavior of floating-point operations where a NaN (Not a Number) input can result in a NaN output, potentially with specific signaling or quieting behavior.
Filed Under: optimizationvectorizationarmsvepr127039