MONDAY, AUGUST 31, 2026
tree-optimization
Fixes wrong code for vectorized reduction by restoring computation order.
Restores correct computation order for vectorized reduction to avoid wrong code.
This commit fixes wrong code generated for vectorized reduction operations by restoring the original computation order of vectype_in. The number of input vector types (vec_in_num) is now computed before the input array is potentially modified, ensuring correctness. A new test case is included to verify the fix.
In Details
A regression introduced by a previous change (r17-3692) caused incorrect vectype_in computation in vect_transform_reduction. This commit reverts the problematic change by restoring the computation of vec_in_num to happen before the input array vec_oprnds is potentially mangled, thus fixing PR127152.
For Context
- vectorized reduction
- A reduction operation (like sum or dot product) that has been optimized to use SIMD instructions, processing multiple data elements in parallel to produce a single result.
- vectype_in
- Represents the data type of the input vector operand within the GCC tree-SSA representation during vectorization.
- vec_in_num
- Indicates the number of vector input operands for a given operation or transformation during the GCC vectorization pass.