tree-optimization/128187 - Vector reductions with single cycle
Fixes vector reduction code generation for operations with non-standard operand counts, like FMA.
This commit resolves an issue in GCC’s vectorization of reductions that are forced into a single cycle, specifically addressing code generation for operations with more or fewer than two operands, such as Fused Multiply-Add (FMA). The change updates the vect_transform_reduction function to correctly handle both two- and three-argument masked internal functions, ensuring accurate code generation for these cases.
In Details
The tree-vect-loop.cc function vect_transform_reduction is updated to correctly handle masked internal functions with varying operand counts, particularly for vector reductions forced to a single cycle. Previously, it assumed exactly two operands, causing incorrect code generation for operations like FMA (which has three operands: destination, operand1, operand2). This patch ensures that both two- and three-argument masked functions are handled properly, resolving PR tree-optimization/128187.
- Vectorization
- An optimization technique that transforms code to operate on multiple data elements simultaneously using special vector instructions.
- Reduction
- A computation that combines elements of a sequence into a single value, such as summing all elements in an array.
- Single cycle
- An optimization goal to complete a complex operation within a single clock cycle, often applicable to vector instructions.
- Fused Multiply-Add (FMA)
- A single instruction that performs both a multiplication and an addition, often used in floating-point computations.
- Masked function
- A function where operations are conditionally applied based on a mask, allowing selective updates to vector elements.
- tree-vect-loop.cc
- A GCC source file containing code related to the vectorization of loops.