GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
vect

vect: Fix scalar iteration bounds for alignment peeling with partial vectors

Corrects scalar loop bounds calculation during alignment peeling to prevent underflow with partial vectors.

A bug in the vectorization pass could cause scalar iteration bounds to underflow when alignment peeling was combined with partial vector execution, particularly on RISC-V. This fix ensures correct calculation of remaining iterations, preventing incorrect loop behavior and potential crashes.

In Details

This commit fixes an integer underflow bug in the vectorizer's alignment peeling logic for loops that utilize partial vectors (e.g., SVE with mrvv-vector-bits=zvl). When LOOP_VINFO_USING_PARTIAL_VECTORS_P is true, the vectorizer previously skipped generating an epilog and an iteration check, which, combined with certain loop bounds, led to an underflow in the calculation of remaining iterations. The fix ensures correct bound calculations in these scenarios, preventing incorrect loop termination or crashes.

For Context
vectorization
The process of transforming a loop to operate on multiple data elements simultaneously using SIMD (Single Instruction, Multiple Data) instructions.
alignment peeling
A loop transformation technique in vectorization where a small number of initial loop iterations are executed separately to align data access with vector register requirements.
partial vectors
In vector processing, refers to operations that do not utilize the full width of the vector registers, often occurring at the end of a loop or when data is not perfectly aligned.
RISC-V SVE
Scalable Vector Extension for the RISC-V architecture, allowing vector registers to dynamically adapt their size.
underflow
An arithmetic condition where a calculation results in a value smaller than the minimum representable value for a given data type, often wrapping around to a large positive number.
Filed Under: vectorizationRISC-Vloop optimization