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 ; [numthreads(1, 1, 1)]
13 ; while (a && ((a || b) && b)) {
20 ; while (x + (x && y)) {
24 ; CHECK: %[[#func_10:]] = OpFunction %[[#void:]] DontInline %[[#]]
25 ; CHECK: %[[#bb54:]] = OpLabel
26 ; CHECK: OpBranch %[[#bb55:]]
27 ; CHECK: %[[#bb55:]] = OpLabel
28 ; CHECK: OpLoopMerge %[[#bb56:]] %[[#bb57:]] None
29 ; CHECK: OpBranch %[[#bb58:]]
30 ; CHECK: %[[#bb58:]] = OpLabel
31 ; CHECK: OpSelectionMerge %[[#bb59:]] None
32 ; CHECK: OpBranchConditional %[[#]] %[[#bb60:]] %[[#bb59:]]
33 ; CHECK: %[[#bb60:]] = OpLabel
34 ; CHECK: OpBranch %[[#bb59:]]
35 ; CHECK: %[[#bb59:]] = OpLabel
36 ; CHECK: OpBranchConditional %[[#]] %[[#bb57:]] %[[#bb56:]]
37 ; CHECK: %[[#bb57:]] = OpLabel
38 ; CHECK: OpBranch %[[#bb55:]]
39 ; CHECK: %[[#bb56:]] = OpLabel
40 ; CHECK: OpBranch %[[#bb61:]]
41 ; CHECK: %[[#bb61:]] = OpLabel
42 ; CHECK: OpLoopMerge %[[#bb62:]] %[[#bb63:]] None
43 ; CHECK: OpBranch %[[#bb64:]]
44 ; CHECK: %[[#bb64:]] = OpLabel
45 ; CHECK: OpSelectionMerge %[[#bb65:]] None
46 ; CHECK: OpBranchConditional %[[#]] %[[#bb65:]] %[[#bb66:]]
47 ; CHECK: %[[#bb66:]] = OpLabel
48 ; CHECK: OpBranch %[[#bb65:]]
49 ; CHECK: %[[#bb65:]] = OpLabel
50 ; CHECK: OpBranchConditional %[[#]] %[[#bb63:]] %[[#bb62:]]
51 ; CHECK: %[[#bb63:]] = OpLabel
52 ; CHECK: OpBranch %[[#bb61:]]
53 ; CHECK: %[[#bb62:]] = OpLabel
54 ; CHECK: OpBranch %[[#bb67:]]
55 ; CHECK: %[[#bb67:]] = OpLabel
56 ; CHECK: OpLoopMerge %[[#bb68:]] %[[#bb69:]] None
57 ; CHECK: OpBranch %[[#bb70:]]
58 ; CHECK: %[[#bb70:]] = OpLabel
59 ; CHECK: OpSelectionMerge %[[#bb71:]] None
60 ; CHECK: OpBranchConditional %[[#]] %[[#bb72:]] %[[#bb71:]]
61 ; CHECK: %[[#bb72:]] = OpLabel
62 ; CHECK: OpSelectionMerge %[[#bb73:]] None
63 ; CHECK: OpBranchConditional %[[#]] %[[#bb74:]] %[[#bb75:]]
64 ; CHECK: %[[#bb74:]] = OpLabel
65 ; CHECK: OpSelectionMerge %[[#bb76:]] None
66 ; CHECK: OpBranchConditional %[[#]] %[[#bb76:]] %[[#bb77:]]
67 ; CHECK: %[[#bb75:]] = OpLabel
68 ; CHECK: %[[#bb77:]] = OpLabel
69 ; CHECK: OpBranchConditional %[[#]] %[[#bb76:]] %[[#bb78:]]
70 ; CHECK: %[[#bb78:]] = OpLabel
71 ; CHECK: OpBranch %[[#bb76:]]
72 ; CHECK: %[[#bb76:]] = OpLabel
73 ; CHECK: OpBranchConditional %[[#]] %[[#bb79:]] %[[#bb73:]]
74 ; CHECK: %[[#bb79:]] = OpLabel
75 ; CHECK: OpBranch %[[#bb73:]]
76 ; CHECK: %[[#bb73:]] = OpLabel
77 ; CHECK: OpBranch %[[#bb71:]]
78 ; CHECK: %[[#bb71:]] = OpLabel
79 ; CHECK: OpBranchConditional %[[#]] %[[#bb69:]] %[[#bb68:]]
80 ; CHECK: %[[#bb69:]] = OpLabel
81 ; CHECK: OpBranch %[[#bb67:]]
82 ; CHECK: %[[#bb68:]] = OpLabel
83 ; CHECK: OpBranch %[[#bb80:]]
84 ; CHECK: %[[#bb80:]] = OpLabel
85 ; CHECK: OpLoopMerge %[[#bb81:]] %[[#bb82:]] None
86 ; CHECK: OpBranch %[[#bb83:]]
87 ; CHECK: %[[#bb83:]] = OpLabel
88 ; CHECK: OpSelectionMerge %[[#bb84:]] None
89 ; CHECK: OpBranchConditional %[[#]] %[[#bb85:]] %[[#bb86:]]
90 ; CHECK: %[[#bb85:]] = OpLabel
91 ; CHECK: OpBranch %[[#bb84:]]
92 ; CHECK: %[[#bb86:]] = OpLabel
93 ; CHECK: OpBranch %[[#bb84:]]
94 ; CHECK: %[[#bb84:]] = OpLabel
95 ; CHECK: OpBranchConditional %[[#]] %[[#bb82:]] %[[#bb81:]]
96 ; CHECK: %[[#bb82:]] = OpLabel
97 ; CHECK: OpBranch %[[#bb80:]]
98 ; CHECK: %[[#bb81:]] = OpLabel
99 ; CHECK: OpBranch %[[#bb87:]]
100 ; CHECK: %[[#bb87:]] = OpLabel
101 ; CHECK: OpLoopMerge %[[#bb88:]] %[[#bb89:]] None
102 ; CHECK: OpBranch %[[#bb90:]]
103 ; CHECK: %[[#bb90:]] = OpLabel
104 ; CHECK: OpSelectionMerge %[[#bb91:]] None
105 ; CHECK: OpBranchConditional %[[#]] %[[#bb92:]] %[[#bb91:]]
106 ; CHECK: %[[#bb92:]] = OpLabel
107 ; CHECK: OpBranch %[[#bb91:]]
108 ; CHECK: %[[#bb91:]] = OpLabel
109 ; CHECK: OpBranchConditional %[[#]] %[[#bb89:]] %[[#bb88:]]
110 ; CHECK: %[[#bb89:]] = OpLabel
111 ; CHECK: OpBranch %[[#bb87:]]
112 ; CHECK: %[[#bb88:]] = OpLabel
114 ; CHECK: OpFunctionEnd
115 ; CHECK: %[[#func_52:]] = OpFunction %[[#void:]] None %[[#]]
116 ; CHECK: %[[#bb93:]] = OpLabel
118 ; CHECK: OpFunctionEnd
122 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
123 target triple = "spirv-unknown-vulkan1.3-compute"
125 ; Function Attrs: convergent noinline norecurse nounwind optnone
126 define internal spir_func void @main() #0 {
128 %0 = call token @llvm.experimental.convergence.entry()
129 %a = alloca i32, align 4
130 %b = alloca i32, align 4
131 %x = alloca i32, align 4
132 %y = alloca i32, align 4
135 while.cond: ; preds = %while.body, %entry
136 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
137 %2 = load i32, ptr %a, align 4
138 %tobool = icmp ne i32 %2, 0
139 br i1 %tobool, label %land.rhs, label %land.end
141 land.rhs: ; preds = %while.cond
142 %3 = load i32, ptr %b, align 4
143 %tobool1 = icmp ne i32 %3, 0
146 land.end: ; preds = %land.rhs, %while.cond
147 %4 = phi i1 [ false, %while.cond ], [ %tobool1, %land.rhs ]
148 br i1 %4, label %while.body, label %while.end
150 while.body: ; preds = %land.end
153 while.end: ; preds = %land.end
154 br label %while.cond2
156 while.cond2: ; preds = %while.body5, %while.end
157 %5 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
158 %6 = load i32, ptr %a, align 4
159 %tobool3 = icmp ne i32 %6, 0
160 br i1 %tobool3, label %lor.end, label %lor.rhs
162 lor.rhs: ; preds = %while.cond2
163 %7 = load i32, ptr %b, align 4
164 %tobool4 = icmp ne i32 %7, 0
167 lor.end: ; preds = %lor.rhs, %while.cond2
168 %8 = phi i1 [ true, %while.cond2 ], [ %tobool4, %lor.rhs ]
169 br i1 %8, label %while.body5, label %while.end6
171 while.body5: ; preds = %lor.end
172 br label %while.cond2
174 while.end6: ; preds = %lor.end
175 br label %while.cond7
177 while.cond7: ; preds = %while.body16, %while.end6
178 %9 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
179 %10 = load i32, ptr %a, align 4
180 %tobool8 = icmp ne i32 %10, 0
181 br i1 %tobool8, label %land.rhs9, label %land.end15
183 land.rhs9: ; preds = %while.cond7
184 %11 = load i32, ptr %a, align 4
185 %tobool10 = icmp ne i32 %11, 0
186 br i1 %tobool10, label %land.rhs12, label %lor.lhs.false
188 lor.lhs.false: ; preds = %land.rhs9
189 %12 = load i32, ptr %b, align 4
190 %tobool11 = icmp ne i32 %12, 0
191 br i1 %tobool11, label %land.rhs12, label %land.end14
193 land.rhs12: ; preds = %lor.lhs.false, %land.rhs9
194 %13 = load i32, ptr %b, align 4
195 %tobool13 = icmp ne i32 %13, 0
198 land.end14: ; preds = %land.rhs12, %lor.lhs.false
199 %14 = phi i1 [ false, %lor.lhs.false ], [ %tobool13, %land.rhs12 ]
202 land.end15: ; preds = %land.end14, %while.cond7
203 %15 = phi i1 [ false, %while.cond7 ], [ %14, %land.end14 ]
204 br i1 %15, label %while.body16, label %while.end17
206 while.body16: ; preds = %land.end15
207 br label %while.cond7
209 while.end17: ; preds = %land.end15
210 br label %while.cond18
212 while.cond18: ; preds = %while.body21, %while.end17
213 %16 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
214 %17 = load i32, ptr %a, align 4
215 %tobool19 = icmp ne i32 %17, 0
216 br i1 %tobool19, label %cond.true, label %cond.false
218 cond.true: ; preds = %while.cond18
219 %18 = load i32, ptr %a, align 4
222 cond.false: ; preds = %while.cond18
223 %19 = load i32, ptr %b, align 4
226 cond.end: ; preds = %cond.false, %cond.true
227 %cond = phi i32 [ %18, %cond.true ], [ %19, %cond.false ]
228 %tobool20 = icmp ne i32 %cond, 0
229 br i1 %tobool20, label %while.body21, label %while.end22
231 while.body21: ; preds = %cond.end
232 br label %while.cond18
234 while.end22: ; preds = %cond.end
235 br label %while.cond23
237 while.cond23: ; preds = %while.body29, %while.end22
238 %20 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
239 %21 = load i32, ptr %x, align 4
240 %22 = load i32, ptr %x, align 4
241 %tobool24 = icmp ne i32 %22, 0
242 br i1 %tobool24, label %land.rhs25, label %land.end27
244 land.rhs25: ; preds = %while.cond23
245 %23 = load i32, ptr %y, align 4
246 %tobool26 = icmp ne i32 %23, 0
249 land.end27: ; preds = %land.rhs25, %while.cond23
250 %24 = phi i1 [ false, %while.cond23 ], [ %tobool26, %land.rhs25 ]
251 %conv = zext i1 %24 to i32
252 %add = add nsw i32 %21, %conv
253 %tobool28 = icmp ne i32 %add, 0
254 br i1 %tobool28, label %while.body29, label %while.end30
256 while.body29: ; preds = %land.end27
257 br label %while.cond23
259 while.end30: ; preds = %land.end27
263 ; Function Attrs: convergent norecurse
264 define void @main.1() #1 {
270 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
271 declare token @llvm.experimental.convergence.entry() #2
273 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
274 declare token @llvm.experimental.convergence.loop() #2
276 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
277 attributes #1 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
278 attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
280 !llvm.module.flags = !{!0, !1, !2}
283 !0 = !{i32 1, !"wchar_size", i32 4}
284 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
285 !2 = !{i32 7, !"frame-pointer", i32 2}