GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
vect

vect: Correct strided gather/scatter offsets with loop peeling

Vectorizer now correctly handles strided gather/scatter offsets when loop peeling is used for alignment, preventing incorrect memory accesses.

This commit refines the vectorizer’s handling of strided gather and scatter operations by accounting for loop peeling used for alignment. Previously, the offset bounds could be incorrectly lowered, leading to potential memory access errors, particularly on AArch64 with SVE. The update ensures that offset bounds are not prematurely reduced, preserving correctness.

In Details

The vect_truncate_gather_scatter_offset helper in GCC's vectorizer was incorrectly bounding strided gather/scatter offsets by the latch iteration count. This commit corrects the logic to not lower the bound when peeling for alignment is being considered, as the masking operation that performs the peeling is not yet known at the time of this bound calculation. This resolves issues with offset wrapping on targets like AArch64 with SVE.

For Context
vectorizer (vect)
A compiler component that transforms loops to operate on multiple data elements simultaneously using SIMD (Single Instruction, Multiple Data) instructions.
loop peeling
A compiler optimization where the first iteration(s) of a loop are duplicated and potentially modified to align data or simplify subsequent loop iterations.
strided gather/scatter
Memory access operations where elements are fetched or stored from/to memory locations with a constant offset between them, often used in vectorization.
SVE
Scalable Vector Extension, an ARM architecture extension providing vector processing capabilities.
offset wrapping
Occurs when an arithmetic calculation involving an offset exceeds the maximum representable value for the data type, causing the value to 'wrap around' to a small number.
Filed Under: vectorizationaarch64SVEoptimization