[Mlir-commits] [mlir] [mlir][RemoveDeadValues] Simplify branch op handling using ub.poison (PR #182711)
Fedor Nikolaev
llvmlistbot at llvm.org
Thu May 14 06:54:31 PDT 2026
================
@@ -808,20 +740,17 @@ void RemoveDeadValues::runOnOperation() {
if (!canonicalize)
return;
- // Canonicalize all region branch ops.
- SmallVector<Operation *> opsToCanonicalize;
- module->walk([&](RegionBranchOpInterface regionBranchOp) {
- opsToCanonicalize.push_back(regionBranchOp.getOperation());
- });
- // Collect all canonicalization patterns for region branch ops.
+ // Canonicalize all region branch ops and branch ops.
RewritePatternSet owningPatterns(context);
DenseSet<RegisteredOperationName> populatedPatterns;
- for (Operation *op : opsToCanonicalize)
+ module->walk([&](Operation *op) {
+ if (!isa<RegionBranchOpInterface, BranchOpInterface>(op))
+ return;
if (std::optional<RegisteredOperationName> info = op->getRegisteredInfo())
if (populatedPatterns.insert(*info).second)
info->getCanonicalizationPatterns(owningPatterns, context);
- if (failed(applyOpPatternsGreedily(opsToCanonicalize,
- std::move(owningPatterns)))) {
+ });
+ if (failed(applyPatternsGreedily(module, std::move(owningPatterns)))) {
----------------
felichita wrote:
@joker-eph I've changed the logic a bit and left the ```applyOpPatternsGreedily``` instead of canonization pass through entire pass by module. Does this address your concern about the canonicalization being too broad?
https://github.com/llvm/llvm-project/pull/182711
More information about the Mlir-commits
mailing list