[mlir][scf] Fix bug in peelForLoop

Insertion point should be set before creating new operations.

Differential Revision: https://reviews.llvm.org/D107326
This commit is contained in:
Matthias Springer 2021-08-04 10:19:53 +09:00
parent f1affe8dc8
commit 767974f344
1 changed files with 1 additions and 0 deletions

View File

@ -116,6 +116,7 @@ LogicalResult mlir::scf::peelForLoop(RewriterBase &b, ForOp forOp,
bindDims(b.getContext(), dim0, dim1, dim2);
// New upper bound: %ub - (%ub - %lb) mod %step
auto modMap = AffineMap::get(3, 0, {dim1 - ((dim1 - dim0) % dim2)});
b.setInsertionPoint(forOp);
Value splitBound = b.createOrFold<AffineApplyOp>(
loc, modMap,
ValueRange{forOp.lowerBound(), forOp.upperBound(), forOp.step()});