[Mlir-commits] [mlir] [MLIR][Affine] Check dependences during MDG init (PR #156422)
Uday Bondhugula
llvmlistbot at llvm.org
Mon Sep 8 04:15:43 PDT 2025
================
@@ -241,7 +241,55 @@ addNodeToMDG(Operation *nodeOp, MemRefDependenceGraph &mdg,
return &node;
}
-bool MemRefDependenceGraph::init() {
+/// Returns true if there may be a dependence on `memref` from srcNode's
+/// memory ops to dstNode's memory ops, while using the affine memory
+/// dependence analysis checks. The method assumes that there is at least one
+/// memory op in srcNode's loads and stores on `memref`, and similarly for
+/// `dstNode`. `srcNode.op` and `destNode.op` are expected to be nested in the
+/// same block and so the dependences are tested at the depth of that block.
+static bool mayDependence(const Node &srcNode, const Node &dstNode,
+ Value memref) {
+ assert(srcNode.op->getBlock() == dstNode.op->getBlock());
+ if (!isa<AffineForOp>(srcNode.op) || !isa<AffineForOp>(dstNode.op))
+ return true;
+
+ // Non-affine stores, can't check. Conservatively, return true.
+ if (!srcNode.memrefStores.empty())
----------------
bondhugula wrote:
Done.
https://github.com/llvm/llvm-project/pull/156422
More information about the Mlir-commits
mailing list