Skip to content

Commit 17b720e

Browse files
authored
[mlir][spirv] Erase empty spirv.mlir.loop in LoopPattern
This PR erases `spirv.mlir.loop` with an empty region in `LoopPattern`, resolving a crash.
1 parent d8b17f2 commit 17b720e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,12 @@ class LoopPattern : public SPIRVToLLVMConversion<spirv::LoopOp> {
10831083
if (loopOp.getLoopControl() != spirv::LoopControl::None)
10841084
return failure();
10851085

1086+
// `spirv.mlir.loop` with empty region is redundant and should be erased.
1087+
if (loopOp.getBody().empty()) {
1088+
rewriter.eraseOp(loopOp);
1089+
return success();
1090+
}
1091+
10861092
Location loc = loopOp.getLoc();
10871093

10881094
// Split the current block after `spirv.mlir.loop`. The remaining ops will

0 commit comments

Comments
 (0)