Refactor vector reduction loop update logic
Code refactoring in vectorization pass simplifies handling of reduction operations and loop bounds.
This commit refactors the vect_reduction_update_partial_vector_usage function in the GCC vectorization pass. The changes defer the recording of loop length and mask to the caller, making the logic easier to reason about and paving the way for future bug fixes (PR126998). The related vect_transform_reduction function is also simplified by removing redundant variables and clarifying vector input calculations.
In Details
The tree-vect-loop.cc file in GCC's middle-end handles loop vectorization. This patch revises how partial vector updates for reduction operations are managed, specifically how loop length and mask information is recorded. By returning a boolean and shifting the responsibility of calling vect_record_loop_{len,mask} to the caller, the code becomes more modular. This change is a preparatory step for addressing issues related to handling complex reduction patterns in PR126998.
- vectorization
- An optimization technique where the compiler transforms code to operate on multiple data elements simultaneously using SIMD (Single Instruction, Multiple Data) instructions. This can significantly speed up array processing and other data-parallel tasks.
- reduction operation
- An operation that combines elements of a sequence into a single value, such as sum, product, minimum, or maximum. In vectorization, these operations are often optimized using specialized vector instructions.
- PR
- Problem Report. GCC uses a public bug tracking system where users report issues and developers track fixes. 'PR tree-optimization/126998' refers to a specific bug report in the tree-optimization component.