GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/tree-vectorizer

Fill match[] on can_duplicate_and_interleave_p failure

Fixes a bug in SLP vectorization where a failed 'duplicate and interleave' check could corrupt internal match data.

This commit addresses a defect in the SLP vectorizer where a failure in the can_duplicate_and_interleave_p check could lead to an improperly populated matches[] array. This condition could occur when trying to create a constant or invariant definition. The fix ensures that matches[] is correctly populated even when this check fails, preventing incorrect data from being used in subsequent operations.

In Details

When the SLP vectorizer in tree-vect-slp.cc attempts to build an SLP tree (specifically in vect_build_slp_tree_2), it calls can_duplicate_and_interleave_p to check if operands can be combined. If this check fails, it may leave the matches[] array in an inconsistent state, potentially using a clobbered version from an earlier operand or failing to report all non-matching lanes. This patch ensures that upon failure of can_duplicate_and_interleave_p, a valid matches[] is constructed, preventing a false sense of success or further incorrect analysis.

For Context
SLP
Slanted Line Processor. A compiler optimization technique that finds vectorization opportunities by identifying identical or similar sequences of scalar instructions that can be executed in parallel on vector hardware. It operates on the intermediate representation after loop optimizations.
Vectorizer
A compiler component responsible for transforming scalar code into vector code, allowing multiple data elements to be processed simultaneously using SIMD (Single Instruction, Multiple Data) instructions. GCC has both loop vectorizers and SLP vectorizers.
Intermediate Representation (IR)
A data structure or code format used internally by a compiler to represent the source code during various stages of translation. GCC uses multiple IRs, including GENERIC and GIMPLE.
Filed Under: gccvectorizationbugfix