[Mlir-commits] [mlir] [MLIR][Affine] Fix private memref creation bug in affine fusion (PR #126028)
Arnab Dutta
llvmlistbot at llvm.org
Thu Feb 6 22:13:16 PST 2025
================
@@ -237,29 +237,67 @@ static void sinkSequentialLoops(MemRefDependenceGraph::Node *node) {
node->op = newRootForOp;
}
-// Creates and returns a private (single-user) memref for fused loop rooted
-// at 'forOp', with (potentially reduced) memref size based on the
-// MemRefRegion written to by 'srcStoreOpInst' at depth 'dstLoopDepth'.
-// TODO: consider refactoring the common code from generateDma and
-// this one.
-static Value createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst,
+/// Get the operation that should act as a dominance filter while replacing
+/// memref uses with a private memref for which `producerStores` and
+/// `sliceInsertionBlock` are provided. This effectively determines in what
+/// part of the IR we should be performing the replacement.
+static Operation *
+getDominanceFilterForPrivateMemRefRepl(Block *sliceInsertionBlock,
+ ArrayRef<Operation *> producerStores) {
+ assert(!producerStores.empty() && "expected producer store");
+
+ // We first find the common block that contains the producer stores and
+ // the slice computation. The first ancestor among the ancestors of the
+ // producer stores in that common block is the dominance filter to use for
+ // replacement.
+ Block *commonBlock = nullptr;
+ // Find the common block of all relevant operations.
+ for (Operation *store : producerStores) {
----------------
arnab-polymage wrote:
You can further inline the ternary expression for otherOp in `findInnermostCommonBlockInScope` function call and remove the l;oop braces.
https://github.com/llvm/llvm-project/pull/126028
More information about the Mlir-commits
mailing list