[Mlir-commits] [mlir] 05901e9 - [mlir][spirv] Add tests for `scf.while` and `scf.for` in `convert-to-spirv` pass (#102528)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Aug 12 14:00:47 PDT 2024
Author: Angel Zhang
Date: 2024-08-12T17:00:44-04:00
New Revision: 05901e980590f721cdc9fbcf1f99353942d0d5d8
URL: https://github.com/llvm/llvm-project/commit/05901e980590f721cdc9fbcf1f99353942d0d5d8
DIFF: https://github.com/llvm/llvm-project/commit/05901e980590f721cdc9fbcf1f99353942d0d5d8.diff
LOG: [mlir][spirv] Add tests for `scf.while` and `scf.for` in `convert-to-spirv` pass (#102528)
This PR adds lit tests that check for `scf.while` and `scf.for`
conversions for the `convert-to-spirv` pass, introduced in #95942.
Added:
Modified:
mlir/test/Conversion/ConvertToSPIRV/scf.mlir
Removed:
################################################################################
diff --git a/mlir/test/Conversion/ConvertToSPIRV/scf.mlir b/mlir/test/Conversion/ConvertToSPIRV/scf.mlir
index 246464928b81c0..350ebcfe57b15b 100644
--- a/mlir/test/Conversion/ConvertToSPIRV/scf.mlir
+++ b/mlir/test/Conversion/ConvertToSPIRV/scf.mlir
@@ -33,6 +33,16 @@ func.func @if_yield(%arg0: i1) -> f32 {
}
// CHECK-LABEL: @while
+// CHECK: spirv.mlir.loop {
+// CHECK: spirv.Branch ^[[HEADER:.*]](%{{.*}} : i32)
+// CHECK: ^[[HEADER]]
+// CHECK: spirv.BranchConditional %{{.*}}, ^[[BODY:.*]](%{{.*}} : i32), ^[[MERGE:.*]]
+// CHECK: ^[[BODY]]
+// CHECK: spirv.Branch
+// CHECK: ^[[MERGE]]
+// CHECK: spirv.mlir.merge
+// CHECK: }
+// CHECK: spirv.Load "Function"
func.func @while(%arg0: i32, %arg1: i32) -> i32 {
%c2_i32 = arith.constant 2 : i32
%0 = scf.while (%arg3 = %arg0) : (i32) -> (i32) {
@@ -45,3 +55,26 @@ func.func @while(%arg0: i32, %arg1: i32) -> i32 {
}
return %0 : i32
}
+
+// CHECK-LABEL: @for
+// CHECK: spirv.mlir.loop {
+// CHECK: spirv.Branch ^[[HEADER:.*]](%{{.*}}, %{{.*}}, %{{.*}} : i32, f32, f32)
+// CHECK: ^[[HEADER]]
+// CHECK: spirv.BranchConditional %{{.*}}, ^[[BODY:.*]], ^[[MERGE:.*]]
+// CHECK: ^[[BODY]]
+// CHECK: spirv.Branch ^[[HEADER]]
+// CHECK: ^[[MERGE]]
+// CHECK: spirv.mlir.merge
+// CHECK: }
+func.func @for() {
+ %lb = arith.constant 4 : index
+ %ub = arith.constant 42 : index
+ %step = arith.constant 2 : index
+ %s0 = arith.constant 0.0 : f32
+ %s1 = arith.constant 1.0 : f32
+ %result:2 = scf.for %i0 = %lb to %ub step %step iter_args(%si = %s0, %sj = %s1) -> (f32, f32) {
+ %sn = arith.addf %si, %si : f32
+ scf.yield %sn, %sn: f32, f32
+ }
+ return
+}
More information about the Mlir-commits
mailing list