diff --git a/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h b/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h --- a/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h +++ b/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h @@ -115,15 +115,17 @@ const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config = GreedyRewriteConfig(), bool *changed = nullptr) { + bool anyRegionChanged = false; bool failed = false; for (Region ®ion : op->getRegions()) { bool regionChanged; failed |= applyPatternsAndFoldGreedily(region, patterns, config, ®ionChanged) .failed(); - if (changed) - *changed |= regionChanged; + anyRegionChanged |= regionChanged; } + if (changed) + *changed = anyRegionChanged; return failure(failed); }