Skip to content

Commit df7545e

Browse files
[mlir][SCF] Fix invalid IR in ParallelOpSingleOrZeroIterationDimsFolder pattern (#74552)
`ParallelOpSingleOrZeroIterationDimsFolder` used to produce invalid IR: ``` within split at mlir/test/Dialect/SCF/canonicalize.mlir:1 offset :11:3: error: 'scf.parallel' op expects region #0 to have 0 or 1 blocks scf.parallel (%i0, %i1, %i2) = (%c0, %c3, %c7) to (%c1, %c6, %c10) step (%c1, %c2, %c3) { ^ within split at mlir/test/Dialect/SCF/canonicalize.mlir:1 offset :11:3: note: see current operation: "scf.parallel"(%4, %5, %3) <{operandSegmentSizes = array<i32: 1, 1, 1, 0>}> ({ ^bb0(%arg1: index): "memref.store"(%0, %arg0, %1, %arg1, %6) : (i32, memref<?x?x?xi32>, index, index, index) -> () "scf.yield"() : () -> () ^bb1(%8: index): // no predecessors "scf.yield"() : () -> () }) : (index, index, index) -> () ``` Together with #74551, this commit fixes `mlir/test/Dialect/SCF/canonicalize.mlir` when verifying the IR after each pattern application (#74270).
1 parent a8d5f73 commit df7545e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mlir/lib/Dialect/SCF/IR/SCF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,8 @@ struct ParallelOpSingleOrZeroIterationDimsFolder
30403040
auto newOp =
30413041
rewriter.create<ParallelOp>(op.getLoc(), newLowerBounds, newUpperBounds,
30423042
newSteps, op.getInitVals(), nullptr);
3043+
// Erase the empty block that was inserted by the builder.
3044+
rewriter.eraseBlock(newOp.getBody());
30433045
// Clone the loop body and remap the block arguments of the collapsed loops
30443046
// (inlining does not support a cancellable block argument mapping).
30453047
rewriter.cloneRegionBefore(op.getRegion(), newOp.getRegion(),

0 commit comments

Comments
 (0)