1 ; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}
4 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
5 target triple = "spirv-unknown-vulkan1.3-compute"
7 ; CHECK-DAG: OpName %[[#process:]] "_Z7processv"
8 ; CHECK-DAG: OpName %[[#fn:]] "_Z2fnv"
9 ; CHECK-DAG: OpName %[[#fn1:]] "_Z3fn1v"
10 ; CHECK-DAG: OpName %[[#fn2:]] "_Z3fn2v"
12 ; CHECK-DAG: OpName %[[#r2m_a:]] ".reg2mem3"
13 ; CHECK-DAG: OpName %[[#r2m_b:]] ".reg2mem1"
14 ; CHECK-DAG: OpName %[[#r2m_c:]] ".reg2mem"
16 ; CHECK-DAG: %[[#int_ty:]] = OpTypeInt 32 0
18 ; CHECK-DAG: %[[#int_0:]] = OpConstant %[[#]] 0
19 ; CHECK-DAG: %[[#int_1:]] = OpConstant %[[#]] 1
20 ; CHECK-DAG: %[[#true:]] = OpConstantTrue
21 ; CHECK-DAG: %[[#false:]] = OpConstantFalse
23 declare token @llvm.experimental.convergence.entry() #1
25 ; CHECK: %[[#fn]] = OpFunction %[[#int_ty]]
26 define spir_func noundef i32 @_Z2fnv() #0 {
28 %0 = call token @llvm.experimental.convergence.entry()
32 ; CHECK: %[[#fn1]] = OpFunction %[[#int_ty]]
33 define spir_func noundef i32 @_Z3fn1v() #0 {
35 %0 = call token @llvm.experimental.convergence.entry()
39 ; CHECK: %[[#fn2]] = OpFunction %[[#int_ty]]
40 define spir_func noundef i32 @_Z3fn2v() #0 {
42 %0 = call token @llvm.experimental.convergence.entry()
46 ; CHECK: %[[#process]] = OpFunction %[[#int_ty]]
47 define spir_func noundef i32 @_Z7processv() #0 {
49 ; CHECK: %[[#entry:]] = OpLabel
50 ; CHECK-DAG: %[[#r2m_a]] = OpVariable %[[#]] Function
51 ; CHECK: OpSelectionMerge %[[#a_merge:]]
52 ; CHECK: OpBranchConditional %[[#]] %[[#a_true:]] %[[#a_false:]]
54 %0 = call token @llvm.experimental.convergence.entry()
56 br i1 true, label %a_true, label %a_false
58 ; CHECK: %[[#a_true]] = OpLabel
59 ; CHECK: OpStore %[[#r2m_a]] %[[#true]]
60 ; CHECK: OpBranch %[[#a_merge]]
64 ; CHECK: %[[#a_false]] = OpLabel
65 ; CHECK: OpStore %[[#r2m_a]] %[[#false]]
66 ; CHECK: OpBranch %[[#a_merge]]
70 ; CHECK: %[[#a_merge]] = OpLabel
71 ; CHECK: %[[#tmp:]] = OpLoad %[[#]] %[[#r2m_a]]
72 ; CHECK: OpSelectionMerge %[[#b_merge:]]
73 ; CHECK: OpBranchConditional %[[#]] %[[#b_true:]] %[[#b_merge]]
75 %1 = phi i1 [ true, %a_true ], [ false, %a_false ]
76 br i1 %1, label %b_true, label %b_merge
78 ; CHECK: %[[#b_true]] = OpLabel
79 ; CHECK: OpBranch %[[#b_merge]]
81 store i32 0, ptr %var ; Prevents whole branch optimization.
84 ; CHECK: %[[#b_merge]] = OpLabel
85 ; CHECK: OpFunctionCall
86 ; CHECK: OpSelectionMerge %[[#c_merge:]]
87 ; CHECK: OpBranchConditional %[[#]] %[[#c_true:]] %[[#c_false:]]
89 %f1 = call spir_func noundef i32 @_Z2fnv() #4 [ "convergencectrl"(token %0) ]
90 br i1 true, label %c_true, label %c_false
92 ; CHECK: %[[#c_true]] = OpLabel
93 ; CHECK: %[[#]] = OpFunctionCall
94 ; CHECK: OpStore %[[#r2m_b]] %[[#]]
95 ; CHECK: OpBranch %[[#c_merge]]
97 %f2 = call spir_func noundef i32 @_Z3fn1v() #4 [ "convergencectrl"(token %0) ]
100 ; CHECK: %[[#c_false]] = OpLabel
101 ; CHECK: %[[#]] = OpFunctionCall
102 ; CHECK: OpStore %[[#r2m_b]] %[[#]]
103 ; CHECK: OpBranch %[[#c_merge]]
105 %f3 = call spir_func noundef i32 @_Z3fn2v() #4 [ "convergencectrl"(token %0) ]
108 ; CHECK: %[[#c_merge]] = OpLabel
109 ; CHECK: %[[#tmp:]] = OpLoad %[[#]] %[[#r2m_b]]
110 ; CHECK: OpStore %[[#r2m_c]] %[[#tmp:]]
111 ; CHECK: OpSelectionMerge %[[#d_merge:]]
112 ; CHECK: OpBranchConditional %[[#]] %[[#d_true:]] %[[#d_merge]]
114 %5 = phi i32 [ %f2, %c_true ], [ %f3, %c_false ]
115 br i1 true, label %d_true, label %d_merge
117 ; CHECK: %[[#d_true]] = OpLabel
118 ; CHECK: OpBranch %[[#d_merge]]
120 store i32 0, ptr %var ; Prevents whole branch optimization.
123 ; CHECK: %[[#d_merge]] = OpLabel
124 ; CHECK: %[[#tmp:]] = OpLoad %[[#]] %[[#r2m_c]]
125 ; CHECK: OpReturnValue %[[#tmp]]
130 ; Function Attrs: convergent noinline norecurse nounwind optnone
131 define internal spir_func void @main() #2 {
133 %0 = call token @llvm.experimental.convergence.entry()
134 %call1 = call spir_func noundef i32 @_Z7processv() #4 [ "convergencectrl"(token %0) ]
138 ; Function Attrs: convergent norecurse
139 define void @main.1() #3 {
145 attributes #0 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
146 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
147 attributes #2 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
148 attributes #3 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
149 attributes #4 = { convergent }
151 !llvm.module.flags = !{!0, !1, !2}
153 !0 = !{i32 1, !"wchar_size", i32 4}
154 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
155 !2 = !{i32 7, !"frame-pointer", i32 2}