File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
lib/Conversion/SPIRVToLLVM
test/Conversion/SPIRVToLLVM Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1148,6 +1148,12 @@ class LoopPattern : public SPIRVToLLVMConversion<spirv::LoopOp> {
1148
1148
if (loopOp.getLoopControl () != spirv::LoopControl::None)
1149
1149
return failure ();
1150
1150
1151
+ // `spirv.mlir.loop` with empty region is redundant and should be erased.
1152
+ if (loopOp.getBody ().empty ()) {
1153
+ rewriter.eraseOp (loopOp);
1154
+ return success ();
1155
+ }
1156
+
1151
1157
Location loc = loopOp.getLoc ();
1152
1158
1153
1159
// Split the current block after `spirv.mlir.loop`. The remaining ops will
Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ spirv.module Logical GLSL450 {
86
86
//===----------------------------------------------------------------------===//
87
87
88
88
spirv.module Logical GLSL450 {
89
+ // CHECK-LABEL: @empty_loop
90
+ spirv.func @empty_loop () " None" {
91
+ // CHECK: llvm.return
92
+ spirv.mlir.loop {
93
+ }
94
+ spirv.Return
95
+ }
96
+
89
97
// CHECK-LABEL: @infinite_loop
90
98
spirv.func @infinite_loop (%count : i32 ) -> () " None" {
91
99
// CHECK: llvm.br ^[[BB1:.*]]
You can’t perform that action at this time.
0 commit comments