[Mlir-commits] [mlir] a123e3c - [mlir] Fix potential crash in hoistRedundantVectorTransfers

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Sep 17 10:05:33 PDT 2021


Author: thomasraoux
Date: 2021-09-17T10:05:20-07:00
New Revision: a123e3c48b5814dba4ec90262192068cd05f755e

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

LOG: [mlir] Fix potential crash in hoistRedundantVectorTransfers

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

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
index bcc047baa949..2c487f010741 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -394,6 +394,13 @@ void mlir::linalg::hoistRedundantVectorTransfers(FuncOp func) {
   bool changed = true;
   while (changed) {
     changed = false;
+    // First move loop invariant ops outside of their loop. This needs to be
+    // done before as we cannot move ops without interputing the function walk.
+    func.walk([&](LoopLikeOpInterface loopLike) {
+      if (failed(moveLoopInvariantCode(loopLike)))
+        llvm_unreachable(
+            "Unexpected failure to move invariant code out of loop");
+    });
 
     func.walk([&](vector::TransferReadOp transferRead) {
       if (!transferRead.getShapedType().isa<MemRefType>())
@@ -407,11 +414,6 @@ void mlir::linalg::hoistRedundantVectorTransfers(FuncOp func) {
       if (!loop)
         return WalkResult::advance();
 
-      if (failed(moveLoopInvariantCode(
-              cast<LoopLikeOpInterface>(loop.getOperation()))))
-        llvm_unreachable(
-            "Unexpected failure to move invariant code out of loop");
-
       LLVM_DEBUG(DBGS() << "Candidate read: " << *transferRead.getOperation()
                         << "\n");
 


        


More information about the Mlir-commits mailing list