[all-commits] [llvm/llvm-project] 2bd872: [LV] Add support for partial alias masking with ta...

Benjamin Maxwell via All-commits all-commits at lists.llvm.org
Tue May 26 16:51:41 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2bd872b03fe16726870a34ee6cb50e9d81947e68
      https://github.com/llvm/llvm-project/commit/2bd872b03fe16726870a34ee6cb50e9d81947e68
  Author: Benjamin Maxwell <benjamin.maxwell at arm.com>
  Date:   2026-05-26 (Tue, 26 May 2026)

  Changed paths:
    M llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
    M llvm/lib/Analysis/VectorUtils.cpp
    M llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
    M llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
    M llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    M llvm/lib/Transforms/Vectorize/VPlan.h
    M llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
    M llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
    M llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
    M llvm/lib/Transforms/Vectorize/VPlanTransforms.h
    M llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
    M llvm/lib/Transforms/Vectorize/VPlanUtils.h
    M llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
    A llvm/test/Transforms/LoopVectorize/AArch64/alias-mask-uniforms.ll
    A llvm/test/Transforms/LoopVectorize/AArch64/alias-mask.ll
    A llvm/test/Transforms/LoopVectorize/AArch64/expensive-alias-masking.ll
    A llvm/test/Transforms/LoopVectorize/RISCV/alias-mask-force-evl.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/pointer-induction.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/tail-folding-interleave.ll
    A llvm/test/Transforms/LoopVectorize/VPlan/AArch64/vplan-printing-alias-mask.ll
    A llvm/test/Transforms/LoopVectorize/VPlan/vplan-printing-alias-mask.ll
    M llvm/test/Transforms/LoopVectorize/VPlan/vplan-printing.ll
    A llvm/test/Transforms/LoopVectorize/alias-mask-data-tail-folding-style.ll
    A llvm/test/Transforms/LoopVectorize/alias-mask-needs-freeze.ll
    A llvm/test/Transforms/LoopVectorize/alias-mask-negative-tests.ll
    A llvm/test/Transforms/LoopVectorize/alias-mask-small-index.ll
    A llvm/test/Transforms/LoopVectorize/alias-mask.ll
    M llvm/test/Transforms/LoopVectorize/cast-induction.ll
    M llvm/test/Transforms/LoopVectorize/pointer-induction.ll
    A llvm/test/Transforms/LoopVectorize/remove-redundant-trip-count-scev.ll
    M llvm/test/Transforms/LoopVectorize/reuse-lcssa-phi-scev-expansion.ll

  Log Message:
  -----------
  [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).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list