[llvm] [LAA] Add initial support for non-power-of-2 store-load forwarding distance (PR #137873)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 05:08:54 PDT 2025


================
@@ -1731,24 +1732,61 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(uint64_t Distance,
       break;
     }
   }
+  // RISCV VLA supports non-power-2 vector factor. So, we iterate in a
+  // backward order to find largest VF, which allows aligned stores-loads or
+  // the number of iterations between conflicting memory addresses is not less
+  // than 8 (NumItersForStoreLoadThroughMemory).
+  if (AllowNonPow2Deps) {
+    MaxVFWithoutSLForwardIssuesNonPowerOf2 =
+        std::min(8 * VectorizerParams::MaxVectorWidth / TypeByteSize,
+                 MaxNonPowerOf2StoreLoadForwardSafeDistanceInBits);
+
+    for (uint64_t VF = MaxVFWithoutSLForwardIssuesNonPowerOf2;
----------------
fhahn wrote:

Why do we count backwards here while forwards for the power-of-2 case?

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


More information about the llvm-commits mailing list