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 %}
5 ; int foo() { return 200; }
13 ; const int t = 3*r+2*s;
43 ; [numthreads(1, 1, 1)]
48 ; CHECK: %[[#func_18:]] = OpFunction %[[#uint:]] DontInline %[[#]]
49 ; CHECK: %[[#bb52:]] = OpLabel
50 ; CHECK: OpReturnValue %[[#]]
51 ; CHECK: OpFunctionEnd
52 ; CHECK: %[[#func_19:]] = OpFunction %[[#uint:]] DontInline %[[#]]
53 ; CHECK: %[[#bb53:]] = OpLabel
54 ; CHECK: OpSelectionMerge %[[#bb54:]] None
55 ; CHECK: OpBranchConditional %[[#]] %[[#bb55:]] %[[#bb56:]]
56 ; CHECK: %[[#bb55:]] = OpLabel
57 ; CHECK: OpSelectionMerge %[[#bb57:]] None
58 ; CHECK: OpBranchConditional %[[#]] %[[#bb58:]] %[[#bb59:]]
59 ; CHECK: %[[#bb56:]] = OpLabel
60 ; CHECK: %[[#bb58:]] = OpLabel
61 ; CHECK: OpSelectionMerge %[[#bb60:]] None
62 ; CHECK: OpBranchConditional %[[#]] %[[#bb61:]] %[[#bb62:]]
63 ; CHECK: %[[#bb59:]] = OpLabel
64 ; CHECK: %[[#bb61:]] = OpLabel
65 ; CHECK: OpSelectionMerge %[[#bb63:]] None
66 ; CHECK: OpSwitch %[[#]] %[[#bb64:]] 1 %[[#bb65:]] 2 %[[#bb63:]] 3 %[[#bb66:]] 140 %[[#bb67:]] 4 %[[#bb68:]] 5 %[[#bb69:]] 6 %[[#bb70:]] 7 %[[#bb71:]]
67 ; CHECK: %[[#bb62:]] = OpLabel
68 ; CHECK: %[[#bb64:]] = OpLabel
69 ; CHECK: OpBranch %[[#bb63:]]
70 ; CHECK: %[[#bb65:]] = OpLabel
71 ; CHECK: OpBranch %[[#bb63:]]
72 ; CHECK: %[[#bb66:]] = OpLabel
73 ; CHECK: OpBranch %[[#bb63:]]
74 ; CHECK: %[[#bb67:]] = OpLabel
75 ; CHECK: OpBranch %[[#bb63:]]
76 ; CHECK: %[[#bb68:]] = OpLabel
77 ; CHECK: OpBranch %[[#bb63:]]
78 ; CHECK: %[[#bb69:]] = OpLabel
79 ; CHECK: OpBranch %[[#bb63:]]
80 ; CHECK: %[[#bb70:]] = OpLabel
81 ; CHECK: OpBranch %[[#bb63:]]
82 ; CHECK: %[[#bb71:]] = OpLabel
83 ; CHECK: OpBranch %[[#bb63:]]
84 ; CHECK: %[[#bb63:]] = OpLabel
85 ; CHECK: OpSelectionMerge %[[#bb72:]] None
86 ; CHECK: OpSwitch %[[#]] %[[#bb73:]] 1 %[[#bb72:]] 2 %[[#bb74:]] 3 %[[#bb75:]]
87 ; CHECK: %[[#bb73:]] = OpLabel
88 ; CHECK: OpBranch %[[#bb72:]]
89 ; CHECK: %[[#bb74:]] = OpLabel
90 ; CHECK: OpBranch %[[#bb72:]]
91 ; CHECK: %[[#bb75:]] = OpLabel
92 ; CHECK: OpBranch %[[#bb72:]]
93 ; CHECK: %[[#bb72:]] = OpLabel
94 ; CHECK: OpBranch %[[#bb60:]]
95 ; CHECK: %[[#bb60:]] = OpLabel
96 ; CHECK: OpSelectionMerge %[[#bb76:]] None
97 ; CHECK: OpSwitch %[[#]] %[[#bb77:]] 1 %[[#bb76:]] 2 %[[#bb78:]]
98 ; CHECK: %[[#bb77:]] = OpLabel
99 ; CHECK: OpBranch %[[#bb76:]]
100 ; CHECK: %[[#bb78:]] = OpLabel
101 ; CHECK: OpBranch %[[#bb76:]]
102 ; CHECK: %[[#bb76:]] = OpLabel
103 ; CHECK: OpBranch %[[#bb57:]]
104 ; CHECK: %[[#bb57:]] = OpLabel
105 ; CHECK: OpBranch %[[#bb54:]]
106 ; CHECK: %[[#bb54:]] = OpLabel
107 ; CHECK: OpReturnValue %[[#]]
108 ; CHECK: OpFunctionEnd
109 ; CHECK: %[[#func_48:]] = OpFunction %[[#void:]] DontInline %[[#]]
110 ; CHECK: %[[#bb79:]] = OpLabel
112 ; CHECK: OpFunctionEnd
113 ; CHECK: %[[#func_50:]] = OpFunction %[[#void:]] None %[[#]]
114 ; CHECK: %[[#bb80:]] = OpLabel
116 ; CHECK: OpFunctionEnd
120 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
121 target triple = "spirv-unknown-vulkan1.3-compute"
123 ; Function Attrs: convergent noinline norecurse nounwind optnone
124 define spir_func noundef i32 @_Z3foov() #0 {
126 %0 = call token @llvm.experimental.convergence.entry()
130 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
131 declare token @llvm.experimental.convergence.entry() #1
133 ; Function Attrs: convergent noinline norecurse nounwind optnone
134 define spir_func noundef i32 @_Z7processv() #0 {
136 %0 = call token @llvm.experimental.convergence.entry()
137 %a = alloca i32, align 4
138 %b = alloca i32, align 4
139 %c = alloca i32, align 4
140 %r = alloca i32, align 4
141 %s = alloca i32, align 4
142 %t = alloca i32, align 4
143 %d = alloca i32, align 4
144 store i32 0, ptr %a, align 4
145 store i32 0, ptr %b, align 4
146 store i32 0, ptr %c, align 4
147 store i32 20, ptr %r, align 4
148 store i32 40, ptr %s, align 4
149 store i32 140, ptr %t, align 4
150 store i32 5, ptr %d, align 4
151 %1 = load i32, ptr %d, align 4
152 switch i32 %1, label %sw.default [
156 i32 140, label %sw.bb7
159 i32 6, label %sw.bb11
160 i32 7, label %sw.bb12
163 sw.bb: ; preds = %entry
164 %2 = load i32, ptr %b, align 4
165 %add = add nsw i32 %2, 1
166 store i32 %add, ptr %b, align 4
167 %call1 = call spir_func noundef i32 @_Z3foov() #3 [ "convergencectrl"(token %0) ]
168 %3 = load i32, ptr %c, align 4
169 %add2 = add nsw i32 %3, %call1
170 store i32 %add2, ptr %c, align 4
173 sw.bb3: ; preds = %entry, %sw.bb
174 %4 = load i32, ptr %b, align 4
175 %add4 = add nsw i32 %4, 2
176 store i32 %add4, ptr %b, align 4
179 sw.bb5: ; preds = %entry
180 %5 = load i32, ptr %b, align 4
181 %add6 = add nsw i32 %5, 3
182 store i32 %add6, ptr %b, align 4
185 sw.bb7: ; preds = %entry
186 %6 = load i32, ptr %b, align 4
187 %add8 = add nsw i32 %6, 140
188 store i32 %add8, ptr %b, align 4
191 sw.bb9: ; preds = %entry, %entry, %sw.bb7
192 %7 = load i32, ptr %b, align 4
193 %add10 = add nsw i32 %7, 5
194 store i32 %add10, ptr %b, align 4
197 sw.bb11: ; preds = %entry
200 sw.bb12: ; preds = %entry, %sw.bb11
203 sw.default: ; preds = %entry
206 sw.epilog: ; preds = %sw.default, %sw.bb12, %sw.bb9, %sw.bb5, %sw.bb3
207 %8 = load i32, ptr %a, align 4
208 %9 = load i32, ptr %b, align 4
209 %add13 = add nsw i32 %8, %9
210 %10 = load i32, ptr %c, align 4
211 %add14 = add nsw i32 %add13, %10
215 ; Function Attrs: convergent noinline norecurse nounwind optnone
216 define internal spir_func void @main() #0 {
218 %0 = call token @llvm.experimental.convergence.entry()
219 %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]
223 ; Function Attrs: convergent norecurse
224 define void @main.1() #2 {
230 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
231 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
232 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
233 attributes #3 = { convergent }
235 !llvm.module.flags = !{!0, !1, !2}
238 !0 = !{i32 1, !"wchar_size", i32 4}
239 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
240 !2 = !{i32 7, !"frame-pointer", i32 2}