[Mlir-commits] [mlir] [mlir][affine] Add visited set to hasDependencePath (PR #199011)

Mehdi Amini llvmlistbot at llvm.org
Tue May 26 04:55:07 PDT 2026


================
@@ -574,6 +574,14 @@ bool MemRefDependenceGraph::hasDependencePath(unsigned srcId,
   SmallVector<std::pair<unsigned, unsigned>, 4> worklist;
   worklist.push_back({srcId, 0});
   Operation *dstOp = getNode(dstId)->op;
+  // Track nodes already pushed onto the worklist. The MDG is a DAG (edges
+  // respect program order), but without a visited set this DFS enumerates
+  // every path from 'srcId' to every reachable node — exponential in the
+  // number of diamond merges. With many independent memref accesses on the
+  // same buffer (e.g. fully-unrolled SIMD-like bodies that load and store
+  // from one buffer between several affine.for loops), this is fatal.
----------------
joker-eph wrote:

```suggestion
  // Track nodes already pushed onto the worklist to avoid redundant visit.
```



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


More information about the Mlir-commits mailing list