|
| 1 | +; RUN: %if spirv-tools %{ spirv-as --target-env spv1.0 %s -o - | mlir-translate --deserialize-spirv - -o - | FileCheck %s %} |
| 2 | + |
| 3 | +; COM: The purpose of this test is to check that in the case where two selections |
| 4 | +; COM: regions share a header / merge block, this block is split and the selection |
| 5 | +; COM: regions are not incorrectly nested. |
| 6 | + |
| 7 | +; CHECK: spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> { |
| 8 | +; CHECK: spirv.func @main() "None" { |
| 9 | +; CHECK: spirv.mlir.selection { |
| 10 | +; CHECK-NEXT: spirv.BranchConditional {{.*}}, ^[[bb:.+]], ^[[bb:.+]] |
| 11 | +; CHECK-NEXT: ^[[bb:.+]] |
| 12 | +; CHECK: spirv.Branch ^[[bb:.+]] |
| 13 | +; CHECK-NEXT: ^[[bb:.+]]: |
| 14 | +; CHECK-NEXT: spirv.mlir.merge |
| 15 | +; CHECK-NEXT: } |
| 16 | +; CHECK: spirv.mlir.selection { |
| 17 | +; CHECK-NEXT: spirv.BranchConditional {{.*}}, ^[[bb:.+]], ^[[bb:.+]] |
| 18 | +; CHECK-NEXT: ^[[bb:.+]] |
| 19 | +; CHECK: spirv.Branch ^[[bb:.+]] |
| 20 | +; CHECK-NEXT: ^[[bb:.+]]: |
| 21 | +; CHECK-NEXT: spirv.mlir.merge |
| 22 | +; CHECK-NEXT: } |
| 23 | +; CHECK: spirv.Return |
| 24 | +; CHECK-NEXT: } |
| 25 | +; CHECK: } |
| 26 | + |
| 27 | + OpCapability Shader |
| 28 | + %2 = OpExtInstImport "GLSL.std.450" |
| 29 | + OpMemoryModel Logical GLSL450 |
| 30 | + OpEntryPoint Fragment %main "main" %colorOut |
| 31 | + OpExecutionMode %main OriginUpperLeft |
| 32 | + OpDecorate %colorOut Location 0 |
| 33 | + %void = OpTypeVoid |
| 34 | + %4 = OpTypeFunction %void |
| 35 | + %float = OpTypeFloat 32 |
| 36 | + %v4float = OpTypeVector %float 4 |
| 37 | +%fun_v4float = OpTypePointer Function %v4float |
| 38 | + %float_1 = OpConstant %float 1 |
| 39 | + %float_0 = OpConstant %float 0 |
| 40 | + %13 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1 |
| 41 | +%out_v4float = OpTypePointer Output %v4float |
| 42 | + %colorOut = OpVariable %out_v4float Output |
| 43 | + %uint = OpTypeInt 32 0 |
| 44 | + %uint_0 = OpConstant %uint 0 |
| 45 | + %out_float = OpTypePointer Output %float |
| 46 | + %bool = OpTypeBool |
| 47 | + %25 = OpConstantComposite %v4float %float_1 %float_1 %float_0 %float_1 |
| 48 | + %main = OpFunction %void None %4 |
| 49 | + %6 = OpLabel |
| 50 | + %color = OpVariable %fun_v4float Function |
| 51 | + OpStore %color %13 |
| 52 | + %19 = OpAccessChain %out_float %colorOut %uint_0 |
| 53 | + %20 = OpLoad %float %19 |
| 54 | + %22 = OpFOrdEqual %bool %20 %float_1 |
| 55 | + OpSelectionMerge %24 None |
| 56 | + OpBranchConditional %22 %23 %24 |
| 57 | + %23 = OpLabel |
| 58 | + OpStore %color %25 |
| 59 | + OpBranch %24 |
| 60 | + %24 = OpLabel |
| 61 | + %30 = OpFOrdEqual %bool %20 %float_1 |
| 62 | + OpSelectionMerge %32 None |
| 63 | + OpBranchConditional %30 %31 %32 |
| 64 | + %31 = OpLabel |
| 65 | + OpStore %color %25 |
| 66 | + OpBranch %32 |
| 67 | + %32 = OpLabel |
| 68 | + %26 = OpLoad %v4float %color |
| 69 | + OpStore %colorOut %26 |
| 70 | + OpReturn |
| 71 | + OpFunctionEnd |
0 commit comments