[Mlir-commits] [mlir] [mlir][reducer] Add eraseAllOpsInRegion function to reduction-tree pass (PR #185892)
Jeremy Kun
llvmlistbot at llvm.org
Sat Mar 14 14:53:09 PDT 2026
================
@@ -145,19 +145,59 @@ static LogicalResult findOptimal(ModuleOp module, Region ®ion,
return success();
}
+/// This function attempts to erase all operations within the region currently
+/// being processed.
+static LogicalResult eraseAllOpsInRegion(ModuleOp module, Region ®ion,
+ const Tester &test) {
+ std::pair<Tester::Interestingness, size_t> initStatus =
+ test.isInteresting(module);
+
+ // While exploring the reduction tree, we always branch from an interesting
+ // node. Thus the root node must be interesting.
+ if (initStatus.first != Tester::Interestingness::True)
+ return module.emitWarning() << "uninterested module will not be reduced";
+ llvm::SpecificBumpPtrAllocator<ReductionNode> allocator;
+
+ // Setting the ranges to {{0, 0}} will result in the deletion of all ops
+ // within the region.
+ std::vector<ReductionNode::Range> ranges{{0, 0}};
+ ReductionNode *root = allocator.Allocate();
+ new (root) ReductionNode(nullptr, ranges, allocator);
----------------
j2kun wrote:
I should be clear: I don't know for sure one way or the other is better. I'm mostly curious about the decision, if you know the reason this convention is used in the other parts of mlir-reduce.
https://github.com/llvm/llvm-project/pull/185892
More information about the Mlir-commits
mailing list