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

Vectorizer queries vec_extract via permute patterns for better accuracy

The GCC vectorizer now queries target `vec_extract` capabilities through a generic permutation pattern, improving synchronization with actual expansion possibi…

This commit enhances the GCC vectorizer’s ability to handle vec_extract operations by querying target capabilities through a permutation pattern (vec_extract_perm_p). Previously, the vectorizer used a direct vec_extract optab check, which might not have perfectly aligned with what the target could actually expand. By using can_vec_extract, which now consults vec_extract_perm_p, the vectorizer is better synchronized with the backend’s capabilities. This change might lead to slightly different codegen in some scalar/vector corner cases, potentially requiring target-level fixes or RTL optimizations.

In Details

This commit refactors tree-vect to query vec_extract support via a generic permutation pattern (vec_extract_perm_p) rather than relying solely on the vec_extract optab. The can_vec_extract function in optabs-query.cc is updated to use this new query mechanism. This change ensures that the vectorizer's understanding of vec_extract capabilities more closely matches the backend's actual expansion capabilities, particularly when dealing with complex subvector extractions that can be implemented using permute operations. A side effect is a slight change in codegen for type punning in…

For Context
Vectorizer
A component of a compiler that automatically transforms scalar code into vector (SIMD) code to improve performance on processors with vector instructions.
vec_extract
An intermediate representation (IR) intrinsic representing the extraction of a subvector from a larger vector register.
optab
Short for 'operation table', a data structure in GCC that maps generic operations to specific machine instructions.
permutation pattern
In vectorization, a pattern that describes rearranging elements within or between vector registers. vec_perm_const is an example.
RTL optimization
Optimizations performed on GCC's Register Transfer Language (RTL), an intermediate representation used in the compiler's backend.
Filed Under: vectorizationoptimizationcompiler