[llvm] [LAA] Prepare to handle diff type sizes v2 (PR #161238)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 03:57:18 PDT 2025


================
@@ -2108,19 +2106,41 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
   if (StrideAScaled == StrideBScaled)
     CommonStride = StrideAScaled;
 
-  // TODO: Historically, we didn't retry with runtime checks when (unscaled)
-  // strides were different but there is no inherent reason to.
-  if (!isa<SCEVConstant>(Dist))
-    ShouldRetryWithRuntimeChecks |= StrideAPtrInt == StrideBPtrInt;
-
   // If distance is a SCEVCouldNotCompute, return Unknown immediately.
   if (isa<SCEVCouldNotCompute>(Dist)) {
     LLVM_DEBUG(dbgs() << "LAA: Uncomputable distance.\n");
     return Dependence::Unknown;
   }
 
+  if (!isa<SCEVConstant>(Dist)) {
+    if (!LoopGuards)
+      LoopGuards.emplace(
+          ScalarEvolution::LoopGuards::collect(InnermostLoop, SE));
+    Dist = SE.applyLoopGuards(Dist, *LoopGuards);
----------------
fhahn wrote:

Could you check compile-time with this? Potentially we are now collecting and applying loop guards in more cases, which can be quite expensive.

I think loop guards also could potentially pessimize  cases where we are not only interested in the possible value ranges, but I can check if this casues any regressions

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


More information about the llvm-commits mailing list