[Mlir-commits] [mlir] [MLIR][Affine] Fix private memref creation bug in affine fusion (PR #126028)
Uday Bondhugula
llvmlistbot at llvm.org
Thu Feb 6 21:53:39 PST 2025
================
@@ -2297,3 +2298,40 @@ FailureOr<AffineValueMap> mlir::affine::simplifyConstrainedMinMaxOp(
affine::canonicalizeMapAndOperands(&newMap, &newOperands);
return AffineValueMap(newMap, newOperands);
}
+
+Block *mlir::affine::findInnermostCommonBlockInScope(Operation *a,
+ Operation *b) {
+ Region *aScope = mlir::affine::getAffineScope(a);
+ Region *bScope = mlir::affine::getAffineScope(b);
+ if (aScope != bScope)
+ return nullptr;
+
+ // Get the block ancestry of `a` while stopping at the affine scope.
+ auto getBlockAncestry = [&](Operation *op,
+ SmallVectorImpl<Block *> &ancestry) {
+ Operation *curOp = op;
+ do {
+ ancestry.push_back(curOp->getBlock());
+ if (curOp->getParentRegion() == aScope)
+ break;
+ curOp = curOp->getParentOp();
+ } while (curOp);
+ assert(curOp && "can't reach root op without passing through affine scope");
+ std::reverse(ancestry.begin(), ancestry.end());
----------------
bondhugula wrote:
llvm::reverse reverses an iteration range - not the elements of a container! Common source of bugs/confusion!
https://github.com/llvm/llvm-project/pull/126028
More information about the Mlir-commits
mailing list