aarch64: Use SVE SPLICE for scalable recurrences
Vectorizer now recognizes and uses the SVE SPLICE instruction for scalable recurrences, improving code generation for certain patterns.
The vectorizer can now represent first-order recurrences as scalable permutations, specifically recognizing the two-input permutation pattern. It builds a predicate for D elements and uses the SVE SPLICE instruction. This change improves code generation by utilizing specialized hardware instructions, as demonstrated by a before-and-after assembly comparison showing more efficient code for a recurrence loop.
In Details
The aarch64 vectorizer previously struggled to represent variable-length permutations required for first-order recurrences. This patch introduces recognition of a specific two-input permutation pattern, constructs a predicate for the D elements, and maps it to the SVE SPLICE instruction. This avoids the generic expansion for such patterns, leading to more efficient code for sequences like b[i] = a[i] - prev; prev = a[i]; when using SVE.
- SVE
- Scalable Vector Extension, an instruction set architecture for ARM processors that allows vector operations to adapt to different vector lengths.
- SPLICE
- An SVE instruction used for combining elements from two vectors based on a predicate, useful for implementing permutations and gather/scatter operations.
- Recurrence
- In program analysis, a recurrence relation is an equation that recursively defines a sequence or multidimensional array of values. In vectorization, this often refers to loop-carried dependencies.
- Predicate
- A condition used in SIMD/vector instructions to control which elements are operated on, allowing for conditional execution or masking.