Skip to content

Commit c02fd17

Browse files
authored
[mlir] [scf] fix crash when conversion from scf to control flow (#107221)
This patch fixed a crash when scf.parallel's region donesn't terminate with reduce op. This can happend in dialect conversion.
1 parent 616a8ce commit c02fd17

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mlir/lib/Conversion/SCFToControlFlow/SCFToControlFlow.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ LogicalResult
482482
ParallelLowering::matchAndRewrite(ParallelOp parallelOp,
483483
PatternRewriter &rewriter) const {
484484
Location loc = parallelOp.getLoc();
485-
auto reductionOp = cast<ReduceOp>(parallelOp.getBody()->getTerminator());
485+
auto reductionOp = dyn_cast<ReduceOp>(parallelOp.getBody()->getTerminator());
486+
if (!reductionOp) {
487+
return failure();
488+
}
486489

487490
// For a parallel loop, we essentially need to create an n-dimensional loop
488491
// nest. We do this by translating to scf.for ops and have those lowered in

0 commit comments

Comments
 (0)