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

SLP: Keep scalar statements for instance roots in externs

Fixes SLP vectorization to prevent errors when instance roots are mentioned in externs of other instances.

This commit fixes a bug in the SLP (superword level parallelism) vectorization pass that caused incorrect code generation when instance roots were referenced in externs of other instances. The fix ensures that instance root statements are kept scalar if they appear in externs, preventing the vectorization that would lead to errors. A new test case is added to verify the fix.

In Details

GCC's SLP vectorizer (in tree-vect-slp.cc) hoists scalar operations into vector ones based on data dependencies and memory aliasing. The transformation has to respect external references, and this patch keeps scalar stmts for instance roots mentioned in externs of other instances.

For Context

Superword Level Parallelism (SLP) is a compiler optimization that transforms scalar operations into vector operations to improve performance. This optimization identifies sequences of independent scalar operations that can be performed in parallel using vector instructions. The compiler needs to be careful when dealing with external references to variables to make sure the transformation is correct.

Filed Under: optimizationvectorizationslp