Use scalar costs for peeling cost estimation in vectorizer.
GCC's vectorizer now uses pre-calculated scalar costs when estimating loop peeling costs, improving accuracy and compile time.
GCC’s vectorizer now uses the scalar_costs summary when computing the peeling cost, avoiding redundant computations. This change replaces repeated walks of LOOP_VINFO_SCALAR_ITERATION_COST and fallbacks to builtin_vectorization_cost with a direct usage of the scalar costs, which should also reduce compile time.
In Details
Loop peeling is a vectorization technique where a few iterations at the beginning or end of a loop are executed serially to enable better alignment for the vectorized loop body. This commit modifies vect_get_known_peeling_cost to use the pre-computed scalar_costs summary instead of repeatedly walking LOOP_VINFO_SCALAR_ITERATION_COST, which leads to more efficient cost estimation for peeling transformations.
For Context
Loop vectorization is a compiler optimization that transforms scalar loops (performing operations on single data elements) into vector loops (performing operations on multiple data elements simultaneously). Loop peeling is a technique used to handle alignment issues by executing a few iterations of the loop separately before the main vectorized loop. This commit improves the accuracy and efficiency of the vectorizer's cost model when estimating the cost of loop peeling by reusing pre-calculated scalar costs.