Skip to content

Commit

Permalink
[mlir] Toy tutorial: insert terminators at the end of the loop during…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
ftynse committed May 20, 2020
1 parent 19e5b2b commit a655144
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a655144

Please sign in to comment.