tree-optimization: Avoid vect_get_num_copies on SLP inputs
Improves vectorization costing by using a new function for SLP inputs.
This commit enhances the vectorization process by avoiding the use of vect_get_num_copies on SLP (Sliding Window Vectorization) inputs during cost estimation. Instead, it introduces and uses vect_get_num_copies_for_invariant for costing, which accurately reflects the number of vector inputs generated by the transform phase and improves the precision of cost-based vectorization decisions.
In Details
Introduces vect_get_num_copies_for_invariant and uses it in vectorizable_lane_reducing within tree-vect-loop.cc to determine the number of vector inputs for costing SLP (Sliding Window Vectorization) idioms. This avoids the less accurate vect_get_num_copies when applied to SLP inputs, ensuring better cost estimation that aligns with the transform phase's actual code generation, potentially improving vectorization profitability.
- tree-optimization
- A phase in the GCC compiler pipeline where code is represented and optimized using an intermediate representation called GENERIC (or 'tree'). This allows for high-level optimizations before code generation.
- SLP (Sliding Window Vectorization)
- A vectorization technique that finds straight-line code sequences that can be executed in parallel using vector instructions, even if they are not part of a loop. It 'slides' a window across the code to find opportunities.
- vectorization
- The process of transforming scalar code (operating on single data elements) into vector code (operating on multiple data elements simultaneously using SIMD instructions) to improve performance.
- costing
- The process by which the compiler estimates the performance impact (e.g., execution time, instruction count) of different code transformations or optimization choices to select the most beneficial one.