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 %}
16 ; {return value;} // Return from function.
17 ; value = 4; // No SPIR-V should be emitted for this statement.
18 ; break; // No SPIR-V should be emitted for this statement.
22 ; {{return value;}} // Return from function.
23 ; value = 6; // No SPIR-V should be emitted for this statement.
26 ; for (int i=0; i<10; ++i) {
28 ; return value; // Return from function.
29 ; return value; // No SPIR-V should be emitted for this statement.
30 ; continue; // No SPIR-V should be emitted for this statement.
31 ; break; // No SPIR-V should be emitted for this statement.
32 ; ++value; // No SPIR-V should be emitted for this statement.
34 ; return value; // Return from function
35 ; continue; // No SPIR-V should be emitted for this statement.
36 ; break; // No SPIR-V should be emitted for this statement.
37 ; ++value; // No SPIR-V should be emitted for this statement.
41 ; // Return from function.
42 ; // Even though this statement will never be executed [because both "if" and "else" above have return statements],
43 ; // SPIR-V code should be emitted for it as we do not analyze the logic.
47 ; // Return from function.
48 ; // Even though this statement will never be executed [because all "case" statements above contain a return statement],
49 ; // SPIR-V code should be emitted for it as we do not analyze the logic.
56 ; [numthreads(1, 1, 1)]
61 ; CHECK: %[[#func_13:]] = OpFunction %[[#uint:]] DontInline %[[#]]
62 ; CHECK: %[[#bb43:]] = OpLabel
63 ; CHECK: OpBranch %[[#bb44:]]
64 ; CHECK: %[[#bb44:]] = OpLabel
65 ; CHECK: OpSelectionMerge %[[#bb45:]] None
66 ; CHECK: OpBranchConditional %[[#]] %[[#bb46:]] %[[#bb47:]]
67 ; CHECK: %[[#bb46:]] = OpLabel
68 ; CHECK: OpSelectionMerge %[[#bb48:]] None
69 ; CHECK: OpSwitch %[[#]] %[[#bb48:]] 1 %[[#bb49:]] 2 %[[#bb50:]] 5 %[[#bb51:]]
70 ; CHECK: %[[#bb47:]] = OpLabel
71 ; CHECK: OpBranch %[[#bb45:]]
72 ; CHECK: %[[#bb49:]] = OpLabel
73 ; CHECK: OpBranch %[[#bb48:]]
74 ; CHECK: %[[#bb50:]] = OpLabel
75 ; CHECK: OpBranch %[[#bb48:]]
76 ; CHECK: %[[#bb51:]] = OpLabel
77 ; CHECK: OpBranch %[[#bb48:]]
78 ; CHECK: %[[#bb48:]] = OpLabel
79 ; CHECK: OpBranchConditional %[[#]] %[[#bb52:]] %[[#bb45:]]
80 ; CHECK: %[[#bb52:]] = OpLabel
81 ; CHECK: OpBranch %[[#bb53:]]
82 ; CHECK: %[[#bb53:]] = OpLabel
83 ; CHECK: OpSelectionMerge %[[#bb54:]] None
84 ; CHECK: OpBranchConditional %[[#]] %[[#bb54:]] %[[#bb55:]]
85 ; CHECK: %[[#bb55:]] = OpLabel
86 ; CHECK: OpBranch %[[#bb54:]]
87 ; CHECK: %[[#bb54:]] = OpLabel
88 ; CHECK: OpBranchConditional %[[#]] %[[#bb56:]] %[[#bb45:]]
89 ; CHECK: %[[#bb56:]] = OpLabel
90 ; CHECK: OpSelectionMerge %[[#bb57:]] None
91 ; CHECK: OpBranchConditional %[[#]] %[[#bb57:]] %[[#bb58:]]
92 ; CHECK: %[[#bb58:]] = OpLabel
93 ; CHECK: OpBranch %[[#bb57:]]
94 ; CHECK: %[[#bb57:]] = OpLabel
95 ; CHECK: OpBranchConditional %[[#]] %[[#bb59:]] %[[#bb45:]]
96 ; CHECK: %[[#bb59:]] = OpLabel
97 ; CHECK: OpBranch %[[#bb45:]]
98 ; CHECK: %[[#bb45:]] = OpLabel
99 ; CHECK: OpReturnValue %[[#]]
100 ; CHECK: OpFunctionEnd
101 ; CHECK: %[[#func_39:]] = OpFunction %[[#void:]] DontInline %[[#]]
102 ; CHECK: %[[#bb60:]] = OpLabel
104 ; CHECK: OpFunctionEnd
105 ; CHECK: %[[#func_41:]] = OpFunction %[[#void:]] None %[[#]]
106 ; CHECK: %[[#bb61:]] = OpLabel
108 ; CHECK: OpFunctionEnd
110 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
111 target triple = "spirv-unknown-vulkan1.3-compute"
113 ; Function Attrs: convergent noinline norecurse nounwind optnone
114 define spir_func noundef i32 @_Z7processv() #0 {
116 %0 = call token @llvm.experimental.convergence.entry()
117 %retval = alloca i32, align 4
118 %cond = alloca i32, align 4
119 %value = alloca i32, align 4
120 %i = alloca i32, align 4
121 store i32 1, ptr %cond, align 4
122 store i32 0, ptr %value, align 4
125 while.cond: ; preds = %entry
126 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
127 %2 = load i32, ptr %value, align 4
128 %cmp = icmp slt i32 %2, 10
129 br i1 %cmp, label %while.body, label %while.end
131 while.body: ; preds = %while.cond
132 %3 = load i32, ptr %value, align 4
133 switch i32 %3, label %sw.default [
139 sw.bb: ; preds = %while.body
140 store i32 1, ptr %value, align 4
141 %4 = load i32, ptr %value, align 4
142 store i32 %4, ptr %retval, align 4
145 sw.bb1: ; preds = %while.body
146 store i32 3, ptr %value, align 4
147 %5 = load i32, ptr %value, align 4
148 store i32 %5, ptr %retval, align 4
151 sw.bb2: ; preds = %while.body
152 store i32 5, ptr %value, align 4
153 %6 = load i32, ptr %value, align 4
154 store i32 %6, ptr %retval, align 4
157 sw.default: ; preds = %while.body
158 store i32 0, ptr %i, align 4
161 for.cond: ; preds = %for.inc, %sw.default
162 %7 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %1) ]
163 %8 = load i32, ptr %i, align 4
164 %cmp3 = icmp slt i32 %8, 10
165 br i1 %cmp3, label %for.body, label %for.end
167 for.body: ; preds = %for.cond
168 %9 = load i32, ptr %cond, align 4
169 %tobool = icmp ne i32 %9, 0
170 br i1 %tobool, label %if.then, label %if.else
172 if.then: ; preds = %for.body
173 %10 = load i32, ptr %value, align 4
174 store i32 %10, ptr %retval, align 4
177 if.else: ; preds = %for.body
178 %11 = load i32, ptr %value, align 4
179 store i32 %11, ptr %retval, align 4
182 for.inc: ; No predecessors!
183 %12 = load i32, ptr %i, align 4
184 %inc = add nsw i32 %12, 1
185 store i32 %inc, ptr %i, align 4
188 for.end: ; preds = %for.cond
189 %13 = load i32, ptr %value, align 4
190 store i32 %13, ptr %retval, align 4
193 while.end: ; preds = %while.cond
194 %14 = load i32, ptr %value, align 4
195 store i32 %14, ptr %retval, align 4
198 return: ; preds = %while.end, %for.end, %if.else, %if.then, %sw.bb2, %sw.bb1, %sw.bb
199 %15 = load i32, ptr %retval, align 4
203 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
204 declare token @llvm.experimental.convergence.entry() #1
206 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
207 declare token @llvm.experimental.convergence.loop() #1
209 ; Function Attrs: convergent noinline norecurse nounwind optnone
210 define internal spir_func void @main() #0 {
212 %0 = call token @llvm.experimental.convergence.entry()
213 %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]
217 ; Function Attrs: convergent norecurse
218 define void @main.1() #2 {
224 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
225 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
226 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
227 attributes #3 = { convergent }
229 !llvm.module.flags = !{!0, !1, !2}
232 !0 = !{i32 1, !"wchar_size", i32 4}
233 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
234 !2 = !{i32 7, !"frame-pointer", i32 2}