Simplify linear load checks using vector permutation utilities
Refactor `is_linear_load_p` to use `vec_perm_indices` for clearer and more robust checking of vector load patterns.
This commit refactors the is_linear_load_p function within the vectorizer to use vec_perm_indices and the series_p() helper. This change simplifies the code, making it easier to verify correctness and preventing the acceptance of invalid permutation patterns, such as the [0 2 2 2] example cited in the bug report. The function now more reliably identifies valid linear load patterns involving complex arithmetic permutations. A new test case for AArch64 is included.
In Details
The is_linear_load_p function in tree-vect-slp-patterns.cc determines if a load operation constitutes a "linear" access pattern, often involving permutations of vector elements, which is crucial for SLP (Superword Level Parallelism) vectorization. Previously implemented with a manual, iterative disqualification process, it was found to be complex and susceptible to errors, accepting invalid patterns. The rewrite leverages vec_perm_indices to directly construct and validate the permutation indices, using series_p() to check for linear sequences. This makes the logic more declarative an…
- Linear Load
- A memory load operation in a vectorized loop where data elements are accessed in a sequential or predictable pattern, often with a constant stride or specific permutation.
- Vector Permutation
- Rearranging the elements within a vector register according to a specified index pattern. This is a common operation in SIMD programming.
- vec_perm_indices
- A function or utility within GCC that helps in constructing or analyzing the indices used for vector permutations.
- SLP (Superword Level Parallelism)
- A compiler optimization technique that vectorizes sequences of independent scalar operations by grouping them into operations on wider data elements (vectors).