Constrain even/odd widen multiplication use
Vectorization of even/odd widening multiplications is now restricted to non-conditional, non-masked, and non-fold-left reductions.
This commit refines the vectorization rules for even/odd widening multiplications to prevent incorrect code generation. The vectorizable_conversion function now correctly constrains the use of these operations, ensuring they are only applied to reduction operations that do not involve conditional logic, masking, or fold-left patterns. This avoids issues where lane-swizzling reduction operations, which are integral to widening multiplications, would not be applicable.
In Details
The vectorizable_conversion function in tree-vect-stmts.cc previously allowed even/odd widening multiplication to be used in reduction operations that might not support lane-swizzling. This commit adds checks to ensure that such reductions are strictly in-order and do not involve masking or fold-left semantics. This is important because widening multiplications rely on specific data movement patterns (lane-swizzling) that are not universally supported by all reduction types, preventing potential ICEs or incorrect vectorization.
- tree-optimization
- A phase in the GCC compiler pipeline that operates on an intermediate representation called GENERIC and GIMPLE, performing various high-level optimizations.
- even/odd widen multiplication
- A vector multiplication operation where the results of two parallel multiplications (e.g., even lanes and odd lanes) are combined or widened into a larger result.
- reduction
- A loop operation that combines elements of a vector or array into a single result (e.g., sum, product, minimum, maximum).
- lane-swizzling
- Reordering or shuffling of elements within a vector register, often used to align data for specific operations.
- masked operation
- A vector operation where only a subset of the vector lanes (determined by a mask) are affected.