Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,12 @@ class LoopPattern : public SPIRVToLLVMConversion<spirv::LoopOp> {
if (loopOp.getLoopControl() != spirv::LoopControl::None)
return failure();

// `spirv.mlir.loop` with empty region is redundant and should be erased.
if (loopOp.getBody().empty()) {
rewriter.eraseOp(loopOp);
return success();
}

Location loc = loopOp.getLoc();

// Split the current block after `spirv.mlir.loop`. The remaining ops will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ spirv.module Logical GLSL450 {
//===----------------------------------------------------------------------===//

spirv.module Logical GLSL450 {
// CHECK-LABEL: @empty_loop
spirv.func @empty_loop() "None" {
// CHECK: llvm.return
spirv.mlir.loop {
}
spirv.Return
}

// CHECK-LABEL: @infinite_loop
spirv.func @infinite_loop(%count : i32) -> () "None" {
// CHECK: llvm.br ^[[BB1:.*]]
Expand Down
Loading