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

Clear LOOP_C_FINITE for scalar prologue/epilogue after vectorization

Ensures scalar loop assumptions are correctly handled after vectorization, preventing confusion for subsequent passes.

This commit addresses an issue where scalar passes could be confused by loop flags after vectorization, particularly for scalar prologue and epilogue loops. When early-break vectorization occurs, assumptions might not be fully recorded in the versioning condition, leading to alternate loop exits. The change clears the LOOP_C_FINITE flag for these scalar loops to ensure correct behavior and accurate assumption propagation for subsequent optimization passes.

In Details

This change in tree-vect-loop-manip.cc clears the LOOP_C_FINITE flag on scalar prologue and epilogue loops when early-break vectorization is performed. Early-break vectorization, when combined with assumptions, might not record all non-main exit conditions in the versioning loop's condition. This can lead subsequent scalar passes to incorrectly assume loop finiteness. Clearing LOOP_C_FINITE ensures these scalar loops are treated appropriately after vectorization, preventing incorrect analysis.

For Context
tree-optimization
An intermediate representation (IR) used by GCC for performing optimizations. 'Tree' refers to the structure of the IR, which resembles an abstract syntax tree.
vectorization
An optimization technique that transforms scalar operations (processing one data item at a time) into vector operations (processing multiple data items simultaneously using SIMD instructions).
scalar prologue/epilogue
Code segments that are executed before (prologue) and after (epilogue) the main vectorized loop. These handle initialization, cleanup, or iterations that cannot be vectorized.
LOOP_C_FINITE
A compiler internal flag or attribute associated with a loop, indicating that the loop is guaranteed to terminate (i.e., it is finite).
Filed Under: optimizationvectorizationbugfix