Skip to content

Commit

Permalink
Setup OpBuilder to support detached block in loopUnrollByFactor (NFC)
Browse files Browse the repository at this point in the history
Setting the builder from a block is looking up for a parent operation
to get a context, instead by setting up the builder with an explicit
context we can support invoking this helper in absence of a parent
operation.
  • Loading branch information
joker-eph committed Apr 1, 2021
1 parent 287c93c commit 51a0718
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mlir/lib/Transforms/Utils/LoopUtils.cpp
Expand Up @@ -1268,8 +1268,9 @@ LogicalResult mlir::loopUnrollByFactor(scf::ForOp forOp,

// Create epilogue clean up loop starting at 'upperBoundUnrolled'.
if (generateEpilogueLoop) {
OpBuilder epilogueBuilder(forOp->getBlock(),
std::next(Block::iterator(forOp)));
OpBuilder epilogueBuilder(forOp->getContext());
epilogueBuilder.setInsertionPoint(forOp->getBlock(),
std::next(Block::iterator(forOp)));
auto epilogueForOp = cast<scf::ForOp>(epilogueBuilder.clone(*forOp));
epilogueForOp.setLowerBound(upperBoundUnrolled);

Expand Down

0 comments on commit 51a0718

Please sign in to comment.