[mlir] Toy tutorial: insert terminators at the end of the loop during rewrite
authorAlex Zinenko <zinenko@google.com>
Wed, 20 May 2020 13:59:44 +0000 (15:59 +0200)
committerAlex Zinenko <zinenko@google.com>
Wed, 20 May 2020 14:12:05 +0000 (16:12 +0200)
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

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

index 58458ff..c6c49ec 100644 (file)
@@ -73,7 +73,7 @@ public:
       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)
index 58458ff..c6c49ec 100644 (file)
@@ -73,7 +73,7 @@ public:
       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)