[Mlir-commits] [mlir] a655144 - [mlir] Toy tutorial: insert terminators at the end of the loop during rewrite

Alex Zinenko llvmlistbot at llvm.org
Wed May 20 07:14:56 PDT 2020


Author: Alex Zinenko
Date: 2020-05-20T16:12:05+02:00
New Revision: a655144f57f8b6a9d5f4ab42b425b1f284353487

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

LOG: [mlir] Toy tutorial: insert terminators at the end of the loop during rewrite

When creating temporary `scf.for` loops in `toy.print` lowering, the block
insertion point was erronously set up to the beginning of the block rather than
to its end, contradicting the comment just above the insertion point change.
The code was nevertheless operational because `scf.for` was setting up its
`scf.yield` terminator in an opaque to the pattern rewriting infrastructure
way. Now that it is about to change, the problem would have been exposed and
lead to conversion failures.

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

Added: 
    

Modified: 
    mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
    mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
index 58458ff4e175..c6c49ec7db6e 100644
--- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
+++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
@@ -73,7 +73,7 @@ class PrintOpLowering : public ConversionPattern {
       loopIvs.push_back(loop.getInductionVar());
 
       // Terminate the loop body.
-      rewriter.setInsertionPointToStart(loop.getBody());
+      rewriter.setInsertionPointToEnd(loop.getBody());
 
       // Insert a newline after each of the inner dimensions of the shape.
       if (i != e - 1)

diff  --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
index 58458ff4e175..c6c49ec7db6e 100644
--- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
+++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
@@ -73,7 +73,7 @@ class PrintOpLowering : public ConversionPattern {
       loopIvs.push_back(loop.getInductionVar());
 
       // Terminate the loop body.
-      rewriter.setInsertionPointToStart(loop.getBody());
+      rewriter.setInsertionPointToEnd(loop.getBody());
 
       // Insert a newline after each of the inner dimensions of the shape.
       if (i != e - 1)


        


More information about the Mlir-commits mailing list