GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc/tree-optimization

Fix fold-left reduction check for vector types.

Correctly checks vector lane count for fold-left reduction, preventing incorrect checks.

This commit corrects a bug in the vectorization pass where the code was checking the vector type instead of the number of lanes for fold-left reduction. This change ensures the correct number of lanes is considered, preventing unnecessary or incorrect reduction handling. A new test case has also been added to verify this fix.

In Details

The vectorization pass uses fold-left reduction for certain operations. This commit corrects tree-vect-slp.cc to compare the total number of lanes with a two-lane special case, rather than comparing the vector type itself. This ensures that reductions are correctly identified and handled, especially in edge cases.

For Context
vectorization
The process of converting scalar operations into vector operations, which can process multiple data elements simultaneously. This is a common optimization technique.
pass
A distinct, self-contained stage within the compiler's optimization pipeline. Each pass performs a specific transformation on the intermediate representation of the code.
fold-left reduction
A type of parallel operation where a binary operation is repeatedly applied to elements of a sequence, accumulating a single result. In vectorization, this allows multiple operations to be performed in parallel.
SLP (Superword Level Parallelism)
A compiler optimization technique that identifies and vectorizes sequences of identical scalar operations that operate on consecutive memory locations.
Filed Under: gccoptimizationvectorization