[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
Tue Mar 10 10:08:15 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:

is it worth doing this analysis in `tryToEnablePartialAliasMasking`?

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


More information about the llvm-commits mailing list