[llvm-branch-commits] [llvm] [LV] Mask off possibly aliasing vector lanes (PR #100579)

Sander de Smalen via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 8 09:05:16 PDT 2025


================
@@ -6752,6 +6776,12 @@ void LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
   if (!MaxFactors) // Cases that should not to be vectorized nor interleaved.
     return;
 
+  ArrayRef<PointerDiffInfo> DiffChecks;
+  auto TFStyle = CM.getTailFoldingStyle();
+  if (RTChecks.has_value() &&
+      useSafeEltsMask(TFStyle, CM.getRTCheckStyle(TFStyle), UserVF, TTI))
+    DiffChecks = *RTChecks;
----------------
sdesmalen-arm wrote:

Why would you want to check that here rather than where it's used (i.e. `tryToBuildVPlanWithVPRecipes`). You can check there if the NoAlias-mask is needed before passing them to `VPlanTransforms::addActiveLaneMask`. That way you don't need to pass the RTChecks to all those functions, thus reducing the diff.

It also seems strange that `RuntimePointerChecking::getDiffChecks` returns a `std::optional<ArrayRef>` rather than an empty ArrayRef, when `CanUseDiffCheck == false`. It would be worth removing the `std::optional` in an NFC patch.

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


More information about the llvm-branch-commits mailing list