GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

Fixes incorrect lane calculation for vector reductions.

Corrects lane calculation in vectorizer to fix wrong code for reduction operations.

This commit fixes an issue in the vectorizer where the calculation of excess lanes for lane-reducing reductions was incorrect. The poly computation for the number of copies for an invariant value is now ensured to be constant, resolving wrong code in vectorized reduction operations. A new test case is added to verify the fix.

In Details

The vectorizer's vect_create_constant_vectors and related functions were incorrectly computing the number of excess lanes for lane-reducing reductions. This commit adjusts the API of vect_get_num_copies_for_invariant to ensure its poly computation is constant and that it correctly outputs the number of excess lanes. This resolves PR126998.

For Context
vectorizer
A compiler component that automatically transforms loops and other code constructs to use SIMD (Single Instruction, Multiple Data) instructions, which can operate on multiple data elements simultaneously for improved performance.
lane-reducing reduction
A type of reduction operation within a vector loop where the results from multiple lanes (parallel computations) are combined into a single value. Examples include sum or dot product.
poly computation
Refers to polynomial computations, often used in compiler optimizations to express relationships between variables or code transformations in a mathematical form.
Filed Under: optimizationvectorizationbugfix