[llvm] [LAA] Allow zero-distance dependences between mixed-width accesses (PR #221531)

Hadong Lee via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 03:56:09 PDT 2026


================
@@ -2377,8 +2377,17 @@ MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
   // Negative distances are not plausible dependencies.
   if (SE.isKnownNonPositive(Dist)) {
     if (SE.isKnownNonNegative(Dist)) {
-      if (HasSameSize) {
-        // Write to the same location with the same size.
+      if (HasSameSize || CommonStride) {
+        // Equal-sized accesses to the same location are forward.
+        //
+        // Invariant from getDependenceDistanceStrideAndSize: both accesses have
+        // non-zero strides in the same direction, each a multiple of its type's
+        // allocation size in bytes.
+        //
+        // When CommonStride is present, its value is therefore at least as
+        // large as either access size. With equal starting addresses, different
+        // iterations cannot overlap, leaving only a loop-independent forward
+        // dependence, even for mixed sizes.
----------------
ChrisLee02 wrote:

https://github.com/llvm/llvm-project/pull/221531/commits/18df6c4e83035e282ad3ec4bebca4d877eafa405

As ASz and BSz cannot be accessed from isDependent directly, I added that assertion in getDependenceDistanceStrideAndSize.

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


More information about the llvm-commits mailing list