[llvm] [DA] Set Distance to zero when Direction is EQ (PR #147966)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 07:17:27 PDT 2025


================
@@ -3991,6 +4003,23 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
     if (CompleteLoops[II])
       Result.DV[II - 1].Scalar = false;
 
+  // Set the distance to zero if the direction is EQ.
+  // TODO: Ideally, the distance should be set to 0 immediately simultaneously
+  // with the corresponding direction being set to EQ.
+  for (unsigned II = 1; II <= Result.getLevels(); ++II) {
+    if (Result.getDirection(II) == Dependence::DVEntry::EQ)
----------------
Meinersbur wrote:

Is it only that Distance is nullptr, or are there cases where it is non-zero but direction is still EQ?

In the former case, could you set the direction only when Distance is nullptr and assert if not `SCEV::isZero`?

In the latter case, the would be something quite wrong. Why prioritize the Direction analysis result over the Distance?

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


More information about the llvm-commits mailing list