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

Assign vertex weight to all SLP nodes, including those without representatives

SLP optimization now assigns vertex weights to all nodes, ensuring consistent cost analysis even for nodes without a representative.

This change ensures that all nodes within GCC’s SLP (Straight-Line-Progression) vectorization process are assigned a vertex weight, which is used for cost-based analysis. Previously, nodes lacking an SLP_TREE_REPRESENTATIVE might not have had their weights initialized, potentially leading to incorrect cost estimations. The vect_slp_node_weight function is updated to use the region entry block for context when a representative is absent, and vect_optimize_slp_pass::start_choosing_layouts now unconditionally assigns a vertex weight to all nodes.

In Details

In GCC's SLP vectorization, SLP_TREE_REPRESENTATIVE identifies a canonical node for a group of equivalent operations. Some nodes, particularly VEC_PERM_EXPR nodes, may not have a representative. The vect_slp_node_weight function calculates a cost weight for each SLP node, used in layout selection. This commit modifies vect_slp_node_weight to accept vinfo (vector information) as context and, when no representative is present, uses the region_entry_block to determine the weight. Furthermore, vect_optimize_slp_pass::start_choosing_layouts now guarantees that a vertex weight is assi…

For Context
SLP vectorization
A compiler optimization technique that identifies sequences of identical or similar instructions operating on different data elements and replaces them with a single vector instruction that operates on multiple data elements simultaneously.
SLP_TREE_REPRESENTATIVE
A flag or pointer within GCC's SLP vectorization framework that identifies a specific node as the canonical representative for a set of equivalent operations.
Vertex weight
In the context of graph-based optimizations like SLP, a 'weight' assigned to a node, likely representing its cost or importance in the optimization process.
Region entry block
The first basic block of a control flow region within the compiler's intermediate representation.
Filed Under: tree-optimizationvectorizationcost-model