[llvm] [LV] Add support for partial alias masking with tail folding (PR #182457)
Gaƫtan Bossu via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 17 04:07:50 PDT 2026
================
@@ -1382,6 +1388,48 @@ class LoopVectorizationCostModel {
return getTailFoldingStyle() != TailFoldingStyle::None;
}
+ void tryToEnablePartialAliasMasking() {
+ assert(!IsPartialAliasMaskingEnabled && "Alias masking already enabled!");
+ assert(foldTailByMasking() && "Expected tail folding to be enabled!");
+ assert(!foldTailWithEVL() &&
+ "Did not expect to enable alias masking with EVL!");
+ // Note: FixedOrderRecurrences are not supported yet as we cannot handle
+ // the required `splice.right` with the alias-mask.
+ if (!ForcePartialAliasingVectorization ||
+ !Legal->getFixedOrderRecurrences().empty())
+ return;
+
+ const RuntimePointerChecking *Checks = Legal->getRuntimePointerChecking();
+ if (!Checks)
+ return;
+
+ auto DiffChecks = Checks->getDiffChecks();
+ if (!DiffChecks || DiffChecks->empty())
+ return;
+
+ for (BasicBlock *BB : TheLoop->blocks()) {
+ for (Instruction &I : *BB) {
+ if (!isa<LoadInst, StoreInst>(I))
----------------
gbossu wrote:
I guess that we currently only expect loads and stores to touch memory. I assume this is guarded somewhere in legality checks. But I think it's worth adding a bit of future-proofing here: either asserting that `!I.mayReadOrWriteMemory()` when it's not a ld/st or disabling alias masking when that is the case.
https://github.com/llvm/llvm-project/pull/182457
More information about the llvm-commits
mailing list