[Mlir-commits] [mlir] [mlir][reducer] Separate Reduction Steps in `findOptimal` and `applyPatterns` (PR #190560)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 8 13:28:53 PDT 2026
================
@@ -125,86 +75,118 @@ static LogicalResult findOptimal(ModuleOp module, Region ®ion,
// the path and apply the reducer to it.
SmallVector<ReductionNode *> trace;
ReductionNode *curNode = smallestNode;
- trace.push_back(curNode);
while (curNode != root) {
- curNode = curNode->getParent();
trace.push_back(curNode);
+ curNode = curNode->getParent();
}
+ if (trace.empty())
+ // If trace is empty, then the smallestNode == root and therefore we were
+ // not successful in reducing the module
+ return failure();
+
// Reduce the region through the optimal path.
while (!trace.empty()) {
ReductionNode *top = trace.pop_back_val();
- applyPatterns(region, patterns, top->getStartRanges(), eraseOpNotInRange);
+ applyFn(region, top->getStartRanges());
}
- if (test.isInteresting(module).first != Tester::Interestingness::True)
+ std::pair<Tester::Interestingness, size_t> finalStatus =
+ test.isInteresting(module);
+
+ if (finalStatus.first != Tester::Interestingness::True)
llvm::report_fatal_error("Reduced module is not interesting");
- if (test.isInteresting(module).second != smallestNode->getSize())
+ if (finalStatus.second != smallestNode->getSize())
----------------
aidint wrote:
This is to avoid multiple execution of test script in case the module is interesting.
https://github.com/llvm/llvm-project/pull/190560
More information about the Mlir-commits
mailing list