[Mlir-commits] [mlir] ff87c4d - [mlir] Fix exiting OpPatternRewriteDriver::simplifyLocally after first iteration that didn't change the op.

Christian Sigg llvmlistbot at llvm.org
Fri Oct 23 02:10:39 PDT 2020


Author: Christian Sigg
Date: 2020-10-23T11:10:31+02:00
New Revision: ff87c4d3e773ae89ae62af20941339f0f252dafd

URL: https://github.com/llvm/llvm-project/commit/ff87c4d3e773ae89ae62af20941339f0f252dafd
DIFF: https://github.com/llvm/llvm-project/commit/ff87c4d3e773ae89ae62af20941339f0f252dafd.diff

LOG: [mlir] Fix exiting OpPatternRewriteDriver::simplifyLocally after first iteration that didn't change the op.

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

Added: 
    

Modified: 
    mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index 14a4c7417249..c6276395d2c2 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -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();


        


More information about the Mlir-commits mailing list