diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp index 3b55704c4ea07..2e7382160f8eb 100644 --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -3040,6 +3040,8 @@ struct ParallelOpSingleOrZeroIterationDimsFolder auto newOp = rewriter.create(op.getLoc(), newLowerBounds, newUpperBounds, newSteps, op.getInitVals(), nullptr); + // Erase the empty block that was inserted by the builder. + rewriter.eraseBlock(newOp.getBody()); // Clone the loop body and remap the block arguments of the collapsed loops // (inlining does not support a cancellable block argument mapping). rewriter.cloneRegionBefore(op.getRegion(), newOp.getRegion(),