[llvm] [LAA] Pass maximum stride to isSafeDependenceDistance. (PR #90036)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 13:55:34 PDT 2024


================
@@ -2046,14 +2046,15 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
 
   ScalarEvolution &SE = *PSE.getSE();
   auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout();
+  uint64_t MaxStride = std::max(StrideA, StrideB);
 
-  // If the distance between the acecsses is larger than their absolute stride
-  // multiplied by the backedge taken count, the accesses are independet, i.e.
-  // they are far enough appart that accesses won't access the same location
-  // across all loop ierations.
-  if (HasSameSize && CommonStride &&
+  // If the distance between the acecsses is larger than their maximum absolute
+  // stride multiplied by the backedge taken count, the accesses are independet,
+  // i.e. they are far enough appart that accesses won't access the same
+  // location across all loop ierations.
+  if (HasSameSize &&
----------------
fhahn wrote:

hey must be non-zero for now which should be ensured here https://github.com/llvm/llvm-project/blob/5db9dd2391d301dfc069bf99e59db000d9b6faaa/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L2002

> Or even better: Use StrideA or StrideB depending on whether Dist is negative or positive.

That sounds like a good improvement that should help additional cases. Would you prefer this pulled in this patch or separate? In any case, I'll first need to add additional test cases to cover this

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


More information about the llvm-commits mailing list