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

tree-optimization: Avoid get_same_sized_vectype in vectorizable_induction

Improves vector type selection in induction variable optimization.

This commit refactors the vectorizable_induction function within the tree optimization passes to avoid using get_same_sized_vectype. Instead, it now uses signed_or_unsigned_type_for to obtain signed or unsigned variants of vector types. This change prevents issues related to the handling of oddball scalar boolean types within get_same_sized_vectype, leading to more robust vectorization of induction variables.

In Details

The vectorizable_induction function in tree-vect-loop.cc previously used get_same_sized_vectype to determine the vector type for induction variables. This function had problematic handling for scalar boolean types. This commit replaces get_same_sized_vectype with signed_or_unsigned_type_for, which directly provides signed or unsigned variants of a given type. This simplifies the type selection logic and avoids the problematic scalar boolean type handling.

For Context
vectorizable_induction
A function within GCC's tree optimization framework that identifies and processes induction variables suitable for vectorization.
induction variable
A variable in a loop that is updated by a constant amount in each iteration, often used as a loop counter.
get_same_sized_vectype
An internal GCC function that attempts to find a vector type of the same size as a given type, sometimes exhibiting issues with specific type kinds.
signed_or_unsigned_type_for
An internal GCC function that returns a signed or unsigned version of a given C type, used for type promotion and consistent handling.
Filed Under: tree-optimizationvectorizationbugfix