llvm-project
2bd872b0 - [LV] Add support for partial alias masking with tail folding (#182457)

Commit
82 days ago
[LV] Add support for partial alias masking with tail folding (#182457) This patch adds basic support for partial alias masking, which allows entering the vector loop even when there is aliasing within a single vector iteration. It does this by clamping the VF to the safe distance between pointers. This allows the runtime VF to be anywhere from 2 to the "static" VF. Conceptually, this transform looks like: ``` // `c` and `b` may alias. for (int i = 0; i < n; i++) { c[i] = a[i] + b[i]; } ``` -> ``` svbool_t alias_mask = loop.dependence.war.mask(b, c); int num_active = num_active_lanes(mask); if (num_active >= 2) { for (int i = 0; i < n; i += num_active) { // ... vector loop masked with `alias_mask` } } // ... scalar tail ``` This initial patch has a number of limitations: - The loop must be tail-folded * We intend to follow-up with full alias-masking support for loops without tail-folding - The mask and transform is only valid for IC = 1 * Some recipes may not handle the "ClampedVF" correctly at IC > 1 * Note: On AArch64, we also only have native alias mask instructions for IC = 1 - Reverse iteration is not supported * The mask reversal logic is not correct for the alias mask (or clamped ALM) - First order recurrences are not supported * The `splice.right` is not lowered correctly for clamped VFs - Reductions are not supported * The final horizontal reduction needs to set lanes past the "ClampedVF" to the identity value - This style of vectorization is not enabled by default/costed * It can be enabled with `-force-partial-aliasing-vectorization` * When enabled, alias masking is used instead of the standard diff checks (when legal to do so) This PR supersedes #100579 (closes #100579).
Author
Parents
Loading