[llvm] [LV] isScalarWithPredication to check for interleaved accesses (PR #194579)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 02:57:32 PDT 2026


=?utf-8?q?Gaƫtan?= Bossu <gaetan.bossu at arm.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/194579 at github.com>


================
@@ -488,8 +489,8 @@ int LoopVectorizationLegality::isConsecutivePtr(Type *AccessTy,
   int Stride = getPtrStride(PSE, AccessTy, Ptr, TheLoop, *DT, Strides,
                             AllowRuntimeSCEVChecks, false)
                    .value_or(0);
-  if (Stride == 1 || Stride == -1)
-    return Stride;
+  if (Stride == int(InterleaveFactor) || Stride == -int(InterleaveFactor))
----------------
david-arm wrote:

I think other people have tried doing something similar here, but I'm not sure it's safe. I realise you've set the default value as 1, so in theory it shouldn't break the usage in `isVectorizableEarlyExitLoop`, however the interface has a completely different meaning when `InterleaveFactor != 1`. The return value is supposed to be the stride in terms of elements, whereas you're now returning a stride in terms of interleave factor. At the very least this significant deviation needs documenting clearly in the interface. However, if we go down this route I personally think it would probably be better to have a completely new interface called `isConsecutiveInterleavePtr` where the user is forced to pass in the interleave factor and think about whether this is the correct interface to be using. Strictly speaking, this only makes sense if there are no holes in the interleave group so really it would require considering all pointers in the same group.

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


More information about the llvm-commits mailing list