[Mlir-commits] [mlir] [mlir][SparseTensor][NFC] Remove `isNestedIn` helper function (PR #75729)
Matthias Springer
llvmlistbot at llvm.org
Sat Dec 16 20:05:01 PST 2023
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/75729
Use `Region::findAncestorBlockInRegion` instead of a custom IR traversal.
>From 9900333f108b7f9fdcda0fdfca62e38cc71976d3 Mon Sep 17 00:00:00 2001
From: Matthias Springer <springerm at google.com>
Date: Sun, 17 Dec 2023 13:03:50 +0900
Subject: [PATCH] [mlir][SparseTensor][NFC] Remove `isNestedIn` helper function
Use `Region::findAncestorBlockInRegion` instead of a custom IR traversal.
---
.../SparseTensor/Transforms/SparseGPUCodegen.cpp | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
index 30ab2a1f18e3f7..69fd1eb746ffe7 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseGPUCodegen.cpp
@@ -1155,7 +1155,7 @@ struct ForallRewriter : public OpRewritePattern<scf::ParallelOp> {
block = arg.getOwner();
else
block = val.getDefiningOp()->getBlock();
- if (!isNestedIn(block, forallOp))
+ if (!forallOp.getRegion().findAncestorBlockInRegion(*block))
invariants.insert(val);
}
});
@@ -1208,15 +1208,6 @@ struct ForallRewriter : public OpRewritePattern<scf::ParallelOp> {
}
private:
- // Helper method to see if block appears in given loop.
- static bool isNestedIn(Block *block, scf::ParallelOp forallOp) {
- for (Operation *o = block->getParentOp(); o; o = o->getParentOp()) {
- if (o == forallOp)
- return true;
- }
- return false;
- }
-
unsigned numThreads;
};
More information about the Mlir-commits
mailing list