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
62 changes: 50 additions & 12 deletions mlir/test/Target/SPIRV/phi.mlir
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// RUN: mlir-translate -no-implicit-module -split-input-file -test-spirv-roundtrip %s | FileCheck %s

// RUN: %if spirv-tools %{ rm -rf %t %}
// RUN: %if spirv-tools %{ mkdir %t %}
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
// RUN: %if spirv-tools %{ spirv-val %t %}

// Test branch with one block argument

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
Expand Down Expand Up @@ -295,15 +300,26 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
%true = spirv.Constant true
%zero = spirv.Constant 0 : i32
%one = spirv.Constant 1 : i32
spirv.mlir.selection {
// CHECK: spirv.BranchConditional %{{.*}}, ^[[true1:.*]](%{{.*}}, %{{.*}} : i32, i32), ^[[false1:.*]]
spirv.BranchConditional %true, ^true1(%zero, %zero: i32, i32), ^false1
spirv.BranchConditional %true, ^true1(%zero, %zero: i32, i32), ^false1
// CHECK: [[true1]](%{{.*}}: i32, %{{.*}}: i32)
^true1(%arg0: i32, %arg1: i32):
spirv.Return
^true1(%arg0: i32, %arg1: i32):
spirv.Return
// CHECK: [[false1]]:
^false1:
^false1:
spirv.Return
^merge:
spirv.mlir.merge
}

spirv.Return
}

spirv.func @main() -> () "None" {
spirv.Return
}
spirv.EntryPoint "GLCompute" @main
}

// -----
Expand All @@ -314,15 +330,26 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
%true = spirv.Constant true
%zero = spirv.Constant 0 : i32
%one = spirv.Constant 1 : i32
spirv.mlir.selection {
// CHECK: spirv.BranchConditional %{{.*}}, ^[[true1:.*]], ^[[false1:.*]](%{{.*}}, %{{.*}} : i32, i32)
spirv.BranchConditional %true, ^true1, ^false1(%zero, %zero: i32, i32)
spirv.BranchConditional %true, ^true1, ^false1(%zero, %zero: i32, i32)
// CHECK: [[true1]]:
^true1:
spirv.Return
^true1:
spirv.Return
// CHECK: [[false1]](%{{.*}}: i32, %{{.*}}: i32):
^false1(%arg0: i32, %arg1: i32):
^false1(%arg0: i32, %arg1: i32):
spirv.Return
^merge:
spirv.mlir.merge
}

spirv.Return
}

spirv.func @main() -> () "None" {
spirv.Return
}
spirv.EntryPoint "GLCompute" @main
}

// -----
Expand All @@ -333,13 +360,24 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
%true = spirv.Constant true
%zero = spirv.Constant 0 : i32
%one = spirv.Constant 1 : i32
spirv.mlir.selection {
// CHECK: spirv.BranchConditional %{{.*}}, ^[[true1:.*]](%{{.*}} : i32), ^[[false1:.*]](%{{.*}}, %{{.*}} : i32, i32)
spirv.BranchConditional %true, ^true1(%one: i32), ^false1(%zero, %zero: i32, i32)
spirv.BranchConditional %true, ^true1(%one: i32), ^false1(%zero, %zero: i32, i32)
// CHECK: [[true1]](%{{.*}}: i32):
^true1(%arg0: i32):
spirv.Return
^true1(%arg0: i32):
spirv.Return
// CHECK: [[false1]](%{{.*}}: i32, %{{.*}}: i32):
^false1(%arg1: i32, %arg2: i32):
^false1(%arg1: i32, %arg2: i32):
spirv.Return
^merge:
spirv.mlir.merge
}

spirv.Return
}

spirv.func @main() -> () "None" {
spirv.Return
}
spirv.EntryPoint "GLCompute" @main
}
25 changes: 21 additions & 4 deletions mlir/test/Target/SPIRV/selection.mlir
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s

// RUN: %if spirv-tools %{ rm -rf %t %}
// RUN: %if spirv-tools %{ mkdir %t %}
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
// RUN: %if spirv-tools %{ spirv-val %t %}

// Selection with both then and else branches

spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
Expand Down Expand Up @@ -136,19 +141,31 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {

// CHECK-NEXT: spirv.Load "Function" %[[VAR]]
%cond = spirv.Load "Function" %var : i1
spirv.mlir.selection {
// CHECK: spirv.BranchConditional %1, ^[[THEN1:.+]](%{{.+}} : i32), ^[[ELSE1:.+]](%{{.+}}, %{{.+}} : i32, i32)
spirv.BranchConditional %cond, ^then1(%one: i32), ^else1(%zero, %zero: i32, i32)
spirv.BranchConditional %cond, ^then1(%one: i32), ^else1(%zero, %zero: i32, i32)

// CHECK-NEXT: ^[[THEN1]](%{{.+}}: i32):
// CHECK-NEXT: spirv.Return
^then1(%arg0: i32):
spirv.Return
^then1(%arg0: i32):
spirv.Return

// CHECK-NEXT: ^[[ELSE1]](%{{.+}}: i32, %{{.+}}: i32):
// CHECK-NEXT: spirv.Return
^else1(%arg1: i32, %arg2: i32):
^else1(%arg1: i32, %arg2: i32):
spirv.Return
^merge:
spirv.mlir.merge
}

spirv.Return
}

spirv.func @main() -> () "None" {
spirv.Return
}
spirv.EntryPoint "GLCompute" @main
spirv.ExecutionMode @main "LocalSize", 1, 1, 1
}

// -----
Expand Down
Loading