Account scalar costs into vect_body.
GCC now records scalar statement costs as part of the vectorized loop body, ensuring accurate cost calculation for vectorization.
GCC’s vectorizer now records the cost of scalar statements as part of the vect_body, rather than the vect_prologue. This ensures that scalar_costs->body_cost () returns a non-zero value, leading to more accurate cost calculations during vectorization.
In Details
In GCC's vectorization framework, the cost of instructions is tracked separately for different parts of the vectorized loop (prologue, body, epilogue). This commit modifies vect_compute_single_scalar_iteration_cost to record statement costs into vect_body instead of vect_prologue, ensuring accurate cost modeling when using scalar_costs.
For Context
Loop vectorization is a compiler optimization that transforms scalar loops (loops that operate on single data elements) into vector loops (loops that operate on multiple data elements simultaneously). The compiler needs to accurately estimate the cost of the original scalar loop and the vectorized loop to determine if vectorization is beneficial. This commit fixes an accounting issue where the cost of scalar statements was incorrectly attributed to the loop prologue instead of the loop body, which could skew the cost analysis.