[PATCH] D76268: [MLIR] Fix op folding to not run pre-replace when not constant folding

Uday Bondhugula via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 19:46:00 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ddd04391d28: [MLIR] Fix op folding to not run pre-replace when not constant folding (authored by bondhugula).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76268/new/

https://reviews.llvm.org/D76268

Files:
  mlir/lib/Transforms/Utils/FoldUtils.cpp


Index: mlir/lib/Transforms/Utils/FoldUtils.cpp
===================================================================
--- mlir/lib/Transforms/Utils/FoldUtils.cpp
+++ mlir/lib/Transforms/Utils/FoldUtils.cpp
@@ -85,17 +85,17 @@
   if (failed(tryToFold(op, results, processGeneratedConstants)))
     return failure();
 
-  // Constant folding succeeded. We will start replacing this op's uses and
-  // eventually erase this op. Invoke the callback provided by the caller to
-  // perform any pre-replacement action.
-  if (preReplaceAction)
-    preReplaceAction(op);
-
   // Check to see if the operation was just updated in place.
   if (results.empty())
     return success();
 
-  // Otherwise, replace all of the result values and erase the operation.
+  // Constant folding succeeded. We will start replacing this op's uses and
+  // erase this op. Invoke the callback provided by the caller to perform any
+  // pre-replacement action.
+  if (preReplaceAction)
+    preReplaceAction(op);
+
+  // Replace all of the result values and erase the operation.
   for (unsigned i = 0, e = results.size(); i != e; ++i)
     op->getResult(i).replaceAllUsesWith(results[i]);
   op->erase();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76268.251537.patch
Type: text/x-patch
Size: 1183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200320/0a45fb87/attachment.bin>


More information about the llvm-commits mailing list