Support two-lane vector BB reductions without target support
GCC can now handle two-lane vector reductions even if the target doesn't explicitly support them, improving vectorization for certain cases.
This commit enhances GCC’s loop vectorization to support reductions with two-lane vectors, even when the target architecture doesn’t provide specific reduc_*_scal optabs for such modes. It allows for more trivial handling of in-order reductions with two lanes. This change addresses issues like PR126028 on x86_64, where the lack of target support prevented optimal instruction matching. Some new, no-op vectorization cases may appear as the cost of vector operations now matches scalar ones in this scenario.
In Details
The tree-vect-slp.cc file, specifically vectorizable_bb_reduc_epilogue, has been updated to handle loop-carried reductions on two-lane vector types. Previously, such reductions often required specific target support (e.g., reduc_*_scal optabs) for efficient epilogue handling. This change introduces a manual, scalar-equivalent fallback for two-lane vector reductions, enabling them even when backend support is missing. This directly impacts SLP (Superword Level Parallelism) vectorization, as demonstrated by fixes for PR126028 and PR54400 on x86_64 which dealt with haddpd instruction mat…
- vector reduction
- An operation that combines elements of a vector into a single scalar value using an associative operator (e.g., sum, product, minimum, maximum).
- two-lane vector
- A vector data type consisting of two elements.
- optabs
- Optimization tables. Data structures used by GCC to store information about available machine instructions and their corresponding operations for optimization purposes.
- SLP vectorization
- Superword Level Parallelism vectorization. A compiler optimization technique that vectorizes sequences of operations on scalars into operations on vectors.
- PR126028
- A GCC bug report number. Bug reports often describe specific issues or regressions found in the compiler.