[mlir] Fix exiting OpPatternRewriteDriver::simplifyLocally after first iteration...
authorChristian Sigg <csigg@google.com>
Fri, 23 Oct 2020 06:29:22 +0000 (08:29 +0200)
committerChristian Sigg <csigg@google.com>
Fri, 23 Oct 2020 09:10:31 +0000 (11:10 +0200)
Before this change, we would run `maxIterations` if the first iteration changed the op.
After this change, we exit the loop as soon as an iteration hasn't changed the op.
Assuming that we have reached a fixed point when an iteration doesn't change the op, this doesn't affect correctness.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D89981

mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp

index 14a4c74..c627639 100644 (file)
@@ -306,6 +306,8 @@ LogicalResult OpPatternRewriteDriver::simplifyLocally(Operation *op,
   // Iterate until convergence or until maxIterations. Deletion of the op as
   // a result of being dead or folded is convergence.
   do {
+    changed = false;
+
     // If the operation is trivially dead - remove it.
     if (isOpTriviallyDead(op)) {
       op->erase();