GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Add vector_costs::add_slp_cost grouping hook.

GCC introduces a hook for targets to correlate cost events from SLP operations, simplifying cost analysis for vectorization.

GCC introduces a vector_costs::add_slp_cost hook, allowing targets to correlate multiple cost events created from a single SLP (Single Loop Prefetch) operation. This simplifies the process for targets to account for the costs associated with SLP vectorization. Targets can implement add_slp_cost to handle specific cases and fall back to the default implementation for unhandled groups, which generates add_stmt_cost events.

In Details

This commit introduces a new virtual function, vector_costs::add_slp_cost, to allow targets to customize cost modelling for SLP vectorization. Instead of changing where costs are recorded, this patch adjusts the submission process. Targets can implement add_slp_cost to handle all or select cases, with a default implementation that generates add_stmt_cost events for unhandled groups. The add_slp_costs function in tree-vect-slp.cc has been updated to dispatch cost vectors in SLP chunks.

For Context

Vectorization is a compiler optimization technique that performs the same operation on multiple data elements simultaneously, improving performance. Deciding whether or not to vectorize a loop requires careful cost analysis. This commit adds a new mechanism that makes it easier for compiler developers to specify the costs associated with vectorizing code using Single Loop Prefetch (SLP), allowing the compiler to make more informed decisions about when to apply this optimization.

Filed Under: vectorizationslpcost analysisoptimization