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: %[[#bb46:]] = OpLabel
63 ; CHECK: OpBranch %[[#bb47:]]
64 ; CHECK: %[[#bb47]] = OpLabel
65 ; CHECK: OpSelectionMerge %[[#bb48:]] None
66 ; CHECK: OpBranchConditional %[[#]] %[[#bb49:]] %[[#bb50:]]
67 ; CHECK: %[[#bb50]] = OpLabel
68 ; CHECK: OpBranch %[[#bb48]]
69 ; CHECK: %[[#bb49]] = OpLabel
70 ; CHECK: OpSelectionMerge %[[#bb51:]] None
71 ; CHECK: OpSwitch %[[#]] %[[#bb51]] 1 %[[#bb52:]] 2 %[[#bb53:]] 5 %[[#bb54:]]
72 ; CHECK: %[[#bb54]] = OpLabel
73 ; CHECK: OpBranch %[[#bb51]]
74 ; CHECK: %[[#bb53]] = OpLabel
75 ; CHECK: OpBranch %[[#bb51]]
76 ; CHECK: %[[#bb52]] = OpLabel
77 ; CHECK: OpBranch %[[#bb51]]
78 ; CHECK: %[[#bb51]] = OpLabel
79 ; CHECK: OpBranchConditional %[[#]] %[[#bb55:]] %[[#bb48]]
80 ; CHECK: %[[#bb55]] = OpLabel
81 ; CHECK: OpBranch %[[#bb56:]]
82 ; CHECK: %[[#bb56]] = OpLabel
83 ; CHECK: OpSelectionMerge %[[#bb57:]] None
84 ; CHECK: OpBranchConditional %[[#]] %[[#bb57]] %[[#bb58:]]
85 ; CHECK: %[[#bb58]] = OpLabel
86 ; CHECK: OpBranch %[[#bb57]]
87 ; CHECK: %[[#bb57]] = OpLabel
88 ; CHECK: OpBranchConditional %[[#]] %[[#bb59:]] %[[#bb48]]
89 ; CHECK: %[[#bb59]] = OpLabel
90 ; CHECK: OpSelectionMerge %[[#bb60:]] None
91 ; CHECK: OpBranchConditional %[[#]] %[[#bb60]] %[[#bb61:]]
92 ; CHECK: %[[#bb61]] = OpLabel
93 ; CHECK: OpBranch %[[#bb60]]
94 ; CHECK: %[[#bb60]] = OpLabel
95 ; CHECK: OpBranchConditional %[[#]] %[[#bb62:]] %[[#bb48]]
96 ; CHECK: %[[#bb62]] = OpLabel
97 ; CHECK: OpBranch %[[#bb48]]
98 ; CHECK: %[[#bb48]] = OpLabel
99 ; CHECK: OpReturnValue %[[#]]
100 ; CHECK: OpFunctionEnd
102 ; CHECK: %[[#func_42:]] = OpFunction %[[#void:]] DontInline %[[#]]
103 ; CHECK: %[[#bb63:]] = OpLabel
105 ; CHECK: OpFunctionEnd
107 ; CHECK: %[[#func_44:]] = OpFunction %[[#void]] None %[[#]]
108 ; CHECK: %[[#bb64:]] = OpLabel
110 ; CHECK: OpFunctionEnd
112 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
113 target triple = "spirv-unknown-vulkan1.3-compute"
115 ; Function Attrs: convergent noinline norecurse nounwind optnone
116 define spir_func noundef i32 @_Z7processv() #0 {
118 %0 = call token @llvm.experimental.convergence.entry()
119 %retval = alloca i32, align 4
120 %cond = alloca i32, align 4
121 %value = alloca i32, align 4
122 %i = alloca i32, align 4
123 store i32 1, ptr %cond, align 4
124 store i32 0, ptr %value, align 4
127 while.cond: ; preds = %entry
128 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
129 %2 = load i32, ptr %value, align 4
130 %cmp = icmp slt i32 %2, 10
131 br i1 %cmp, label %while.body, label %while.end
133 while.body: ; preds = %while.cond
134 %3 = load i32, ptr %value, align 4
135 switch i32 %3, label %sw.default [
141 sw.bb: ; preds = %while.body
142 store i32 1, ptr %value, align 4
143 %4 = load i32, ptr %value, align 4
144 store i32 %4, ptr %retval, align 4
147 sw.bb1: ; preds = %while.body
148 store i32 3, ptr %value, align 4
149 %5 = load i32, ptr %value, align 4
150 store i32 %5, ptr %retval, align 4
153 sw.bb2: ; preds = %while.body
154 store i32 5, ptr %value, align 4
155 %6 = load i32, ptr %value, align 4
156 store i32 %6, ptr %retval, align 4
159 sw.default: ; preds = %while.body
160 store i32 0, ptr %i, align 4
163 for.cond: ; preds = %for.inc, %sw.default
164 %7 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %1) ]
165 %8 = load i32, ptr %i, align 4
166 %cmp3 = icmp slt i32 %8, 10
167 br i1 %cmp3, label %for.body, label %for.end
169 for.body: ; preds = %for.cond
170 %9 = load i32, ptr %cond, align 4
171 %tobool = icmp ne i32 %9, 0
172 br i1 %tobool, label %if.then, label %if.else
174 if.then: ; preds = %for.body
175 %10 = load i32, ptr %value, align 4
176 store i32 %10, ptr %retval, align 4
179 if.else: ; preds = %for.body
180 %11 = load i32, ptr %value, align 4
181 store i32 %11, ptr %retval, align 4
184 for.inc: ; No predecessors!
185 %12 = load i32, ptr %i, align 4
186 %inc = add nsw i32 %12, 1
187 store i32 %inc, ptr %i, align 4
190 for.end: ; preds = %for.cond
191 %13 = load i32, ptr %value, align 4
192 store i32 %13, ptr %retval, align 4
195 while.end: ; preds = %while.cond
196 %14 = load i32, ptr %value, align 4
197 store i32 %14, ptr %retval, align 4
200 return: ; preds = %while.end, %for.end, %if.else, %if.then, %sw.bb2, %sw.bb1, %sw.bb
201 %15 = load i32, ptr %retval, align 4
205 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
206 declare token @llvm.experimental.convergence.entry() #1
208 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
209 declare token @llvm.experimental.convergence.loop() #1
211 ; Function Attrs: convergent noinline norecurse nounwind optnone
212 define internal spir_func void @main() #0 {
214 %0 = call token @llvm.experimental.convergence.entry()
215 %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]
219 ; Function Attrs: convergent norecurse
220 define void @main.1() #2 {
226 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
227 attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
228 attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
229 attributes #3 = { convergent }
231 !llvm.module.flags = !{!0, !1, !2}
234 !0 = !{i32 1, !"wchar_size", i32 4}
235 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
236 !2 = !{i32 7, !"frame-pointer", i32 2}