[llvm] [LV] Add support for partial alias masking with tail folding (PR #182457)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 11 01:35:38 PDT 2026


================
@@ -3072,10 +3112,17 @@ bool LoopVectorizationCostModel::memoryInstructionCanBeWidened(
   auto *Ptr = getLoadStorePointerOperand(I);
   auto *ScalarTy = getLoadStoreType(I);
 
+  int Stride = Legal->isConsecutivePtr(ScalarTy, Ptr);
   // In order to be widened, the pointer should be consecutive, first of all.
-  if (!Legal->isConsecutivePtr(ScalarTy, Ptr))
+  if (!Stride)
     return false;
 
+  // Currently, we can't handle alias masking in reverse. Reversing the alias
+  // mask is not correct (or necessary). When combined with tail-folding the ALM
+  // should only be reversed where the alias-mask is true.
+  if (Stride < 0)
+    disablePartialAliasMaskingIfEnabled();
----------------
sdesmalen-arm wrote:

Can't the `Loop *` be passed to  `tryToEnablePartialAliasMasking`? (and then traversed)
At least that way, all decision making logic on whether to enable partial alias masking is contained in one place.

https://github.com/llvm/llvm-project/pull/182457


More information about the llvm-commits mailing list