Re: Uncounted loop vectorization example doesn't work with unsigned index
Project / Subsystem
gcc / gcc
Date
2026-05-12
Proposer
Richard Biener <richard.guenther@gmail.com>
Source type
public_inbox
Consensus
Proposed
Sentiment
—/10
Technical tradeoffs
- • Vectorizing loops can improve performance, but not all loops are suitable for vectorization.
- • The compiler's cost model may prevent vectorization if it deems it unprofitable.
- • Unsigned loop indices can sometimes hinder the compiler's ability to estimate the number of iterations.
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- discussion_id
- CAFiYyc0oSQ76NmAYDdcGTqpJcWb=FSV-cTqiXfnDiogaog-E3g@mail.gmail.com
- source_type
- public_inbox
- title
- Re: Uncounted loop vectorization example doesn't work with unsigned index
- headline
- Uncounted loop vectorization example doesn't work with unsigned index
- tldr
- Richard Biener investigates why certain seemingly vectorizable loops with unsigned indices are not being vectorized by GCC, pointing to cost model issues.
- proposer
- Richard Biener <richard.guenther@gmail.com>
- consensus
- Proposed
- outcome
- proposed
- sentiment_score
- —
- technical_tradeoffs
-
- • Vectorizing loops can improve performance, but not all loops are suitable for vectorization.
- • The compiler's cost model may prevent vectorization if it deems it unprofitable.
- • Unsigned loop indices can sometimes hinder the compiler's ability to estimate the number of iterations.
- series_id
- —
- series_role
- standalone
- series_parts
- []
- tags
-
- • gcc
- • vectorization
- • loop optimization
- • cost model
- url
- https://inbox.sourceware.org/gcc/CAFiYyc0oSQ76NmAYDdcGTqpJcWb=FSV-cTqiXfnDiogaog-E3g@mail.gmail.com
- bugzilla_url
- —
- date
- 2026-05-12T00:00:00.000Z
Re: Uncounted loop vectorization example doesn't work with unsigned index
Richard Biener is debugging why a loop using an unsigned long index is not being vectorized, while the same loop with a long index is. He finds the vectorization is disabled by the cost model. Using -fno-vect-cost-model enables vectorization, but this is not the default, indicating the compiler’s cost analysis deems it unprofitable. The discussion highlights the nuances of loop vectorization and the impact of index types on the compiler’s cost estimation.