diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp @@ -717,7 +717,8 @@ rewriter.setInsertionPoint(innerWarp.getBody(), innerWarp.getBody()->end()); rewriter.create(innerWarp.getLoc(), yieldOperands); rewriter.setInsertionPointAfter(innerWarp); - rewriter.create(forOp.getLoc(), innerWarp.getResults()); + if (!innerWarp.getResults().empty()) + rewriter.create(forOp.getLoc(), innerWarp.getResults()); rewriter.eraseOp(forOp); // Replace the warpOp result coming from the original ForOp. for (const auto &res : llvm::enumerate(resultIdx)) { diff --git a/mlir/test/Dialect/Vector/vector-warp-distribute.mlir b/mlir/test/Dialect/Vector/vector-warp-distribute.mlir --- a/mlir/test/Dialect/Vector/vector-warp-distribute.mlir +++ b/mlir/test/Dialect/Vector/vector-warp-distribute.mlir @@ -387,6 +387,26 @@ // ----- +// CHECK-PROP-LABEL: func @warp_scf_for_swap_no_yield( +// CHECK-PROP: scf.for %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} { +// CHECK-PROP-NEXT: vector.warp_execute_on_lane_0(%{{.*}})[32] { +// CHECK-PROP-NEXT: "some_op"() : () -> () +// CHECK-PROP-NEXT: } +// CHECK-PROP-NEXT: } +func.func @warp_scf_for_swap_no_yield(%arg0: index) { + %c128 = arith.constant 128 : index + %c1 = arith.constant 1 : index + %c0 = arith.constant 0 : index + vector.warp_execute_on_lane_0(%arg0)[32] { + scf.for %arg3 = %c0 to %c128 step %c1 { + "some_op"() : () -> () + } + } + return +} + +// ----- + #map = affine_map<()[s0] -> (s0 * 4)> #map1 = affine_map<()[s0] -> (s0 * 128 + 128)> #map2 = affine_map<()[s0] -> (s0 * 4 + 128)>