Fix SLP pattern representative checks for VEC_PERM nodes.
Corrects SLP vectorization by properly handling VEC_PERM nodes in pattern comparisons.
This commit fixes an issue in the SLP (Superword Level Parallelism) vectorization pass where comparisons of complex nodes failed due to improper handling of VEC_PERM nodes. When these nodes still had a representative, the comparison logic incorrectly used arbitrary operations, leading to incorrect vectorization decisions. The fix ensures that VEC_PERM nodes are special-cased, preventing erroneous comparisons and improving the accuracy of vectorization.
In Details
The SLP vectorizer in GCC uses compatible_complex_nodes_p to determine if two GIMPLE nodes can be part of the same vector operation. This function was incorrectly comparing VEC_PERM nodes when they still held a representative. This commit adds a special case for VEC_PERM to compatible_complex_nodes_p, ensuring that these specific permutation nodes are handled correctly and do not cause the SLP pass to misidentify compatible operations, thus avoiding incorrect vectorization.
- SLP
- Superword Level Parallelism, an optimization technique that enables the compiler to identify and vectorize sequences of identical operations on different data elements.
- VEC_PERM
- A GIMPLE operation representing a vector permutation, where elements from one or more vectors are rearranged to form a new vector.
- tree-optimization
- GCC's optimization passes that operate on the GIMPLE intermediate representation.
- vectorization
- The process of transforming code to use SIMD (Single Instruction, Multiple Data) instructions, allowing a single instruction to operate on multiple data elements simultaneously.