Debian Codegraph @

llvm/test/CodeGen/SPIRV/structurizer/cf.while.short-circuited-cond.ll

raw
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 %}
3
4 ;
5 ; [numthreads(1, 1, 1)]
6 ; void main() {
7 ; int a, b;
8 ; while (a && b) {
9 ; }
10 ;
11 ; while (a || b) {
12 ; }
13 ; while (a && ((a || b) && b)) {
14 ; }
15 ;
16 ; while (a ? a : b) {
17 ; }
18 ;
19 ; int x, y;
20 ; while (x + (x && y)) {
21 ; }
22 ; }
23
24 ; CHECK: %[[#func_11:]] = OpFunction %[[#void:]] DontInline %[[#]]
25 ; CHECK: %[[#bb87:]] = OpLabel
26 ; CHECK: OpBranch %[[#bb88:]]
27 ; CHECK: %[[#bb88]] = OpLabel
28 ; CHECK: OpLoopMerge %[[#bb89:]] %[[#bb90:]] None
29 ; CHECK: OpBranch %[[#bb91:]]
30 ; CHECK: %[[#bb91]] = OpLabel
31 ; CHECK: OpSelectionMerge %[[#bb92:]] None
32 ; CHECK: OpBranchConditional %[[#]] %[[#bb93:]] %[[#bb94:]]
33 ; CHECK: %[[#bb94]] = OpLabel
34 ; CHECK: OpBranch %[[#bb92]]
35 ; CHECK: %[[#bb93]] = OpLabel
36 ; CHECK: OpBranch %[[#bb92]]
37 ; CHECK: %[[#bb92]] = OpLabel
38 ; CHECK: OpBranchConditional %[[#]] %[[#bb90]] %[[#bb89]]
39 ; CHECK: %[[#bb89]] = OpLabel
40 ; CHECK: OpBranch %[[#bb95:]]
41 ; CHECK: %[[#bb95]] = OpLabel
42 ; CHECK: OpLoopMerge %[[#bb96:]] %[[#bb97:]] None
43 ; CHECK: OpBranch %[[#bb98:]]
44 ; CHECK: %[[#bb98]] = OpLabel
45 ; CHECK: OpSelectionMerge %[[#bb99:]] None
46 ; CHECK: OpBranchConditional %[[#]] %[[#bb100:]] %[[#bb101:]]
47 ; CHECK: %[[#bb101]] = OpLabel
48 ; CHECK: OpBranch %[[#bb99]]
49 ; CHECK: %[[#bb100]] = OpLabel
50 ; CHECK: OpBranch %[[#bb99]]
51 ; CHECK: %[[#bb99]] = OpLabel
52 ; CHECK: OpBranchConditional %[[#]] %[[#bb97]] %[[#bb96]]
53 ; CHECK: %[[#bb96]] = OpLabel
54 ; CHECK: OpBranch %[[#bb102:]]
55 ; CHECK: %[[#bb102]] = OpLabel
56 ; CHECK: OpLoopMerge %[[#bb103:]] %[[#bb104:]] None
57 ; CHECK: OpBranch %[[#bb105:]]
58 ; CHECK: %[[#bb105]] = OpLabel
59 ; CHECK: OpSelectionMerge %[[#bb106:]] None
60 ; CHECK: OpBranchConditional %[[#]] %[[#bb107:]] %[[#bb108:]]
61 ; CHECK: %[[#bb108]] = OpLabel
62 ; CHECK: OpBranch %[[#bb106]]
63 ; CHECK: %[[#bb107]] = OpLabel
64 ; CHECK: OpSelectionMerge %[[#bb109:]] None
65 ; CHECK: OpBranchConditional %[[#]] %[[#bb110:]] %[[#bb109]]
66 ; CHECK: %[[#bb110]] = OpLabel
67 ; CHECK: OpSelectionMerge %[[#bb111:]] None
68 ; CHECK: OpBranchConditional %[[#]] %[[#bb112:]] %[[#bb113:]]
69 ; CHECK: %[[#bb113]] = OpLabel
70 ; CHECK: OpSelectionMerge %[[#bb114:]] None
71 ; CHECK: OpBranchConditional %[[#]] %[[#bb114]] %[[#bb115:]]
72 ; CHECK: %[[#bb115]] = OpLabel
73 ; CHECK: OpBranch %[[#bb114]]
74 ; CHECK: %[[#bb114]] = OpLabel
75 ; CHECK: OpBranchConditional %[[#]] %[[#bb116:]] %[[#bb111]]
76 ; CHECK: %[[#bb116]] = OpLabel
77 ; CHECK: OpBranch %[[#bb111]]
78 ; CHECK: %[[#bb112]] = OpLabel
79 ; CHECK: OpBranch %[[#bb111]]
80 ; CHECK: %[[#bb111]] = OpLabel
81 ; CHECK: OpBranchConditional %[[#]] %[[#bb109]] %[[#bb117:]]
82 ; CHECK: %[[#bb117]] = OpLabel
83 ; CHECK: OpBranch %[[#bb109]]
84 ; CHECK: %[[#bb109]] = OpLabel
85 ; CHECK: OpBranchConditional %[[#]] %[[#bb106]] %[[#bb118:]]
86 ; CHECK: %[[#bb118]] = OpLabel
87 ; CHECK: OpBranch %[[#bb106]]
88 ; CHECK: %[[#bb106]] = OpLabel
89 ; CHECK: OpSelectionMerge %[[#bb119:]] None
90 ; CHECK: OpBranchConditional %[[#]] %[[#bb119]] %[[#bb120:]]
91 ; CHECK: %[[#bb120]] = OpLabel
92 ; CHECK: %[[#bb119]] = OpLabel
93 ; CHECK: OpBranchConditional %[[#]] %[[#bb104]] %[[#bb103]]
94 ; CHECK: %[[#bb103]] = OpLabel
95 ; CHECK: OpBranch %[[#bb121:]]
96 ; CHECK: %[[#bb121]] = OpLabel
97 ; CHECK: OpLoopMerge %[[#bb122:]] %[[#bb123:]] None
98 ; CHECK: OpBranch %[[#bb124:]]
99 ; CHECK: %[[#bb124]] = OpLabel
100 ; CHECK: OpSelectionMerge %[[#bb125:]] None
101 ; CHECK: OpBranchConditional %[[#]] %[[#bb126:]] %[[#bb127:]]
102 ; CHECK: %[[#bb127]] = OpLabel
103 ; CHECK: OpBranch %[[#bb125]]
104 ; CHECK: %[[#bb126]] = OpLabel
105 ; CHECK: OpBranch %[[#bb125]]
106 ; CHECK: %[[#bb125]] = OpLabel
107 ; CHECK: OpBranchConditional %[[#]] %[[#bb123]] %[[#bb122]]
108 ; CHECK: %[[#bb122]] = OpLabel
109 ; CHECK: OpBranch %[[#bb128:]]
110 ; CHECK: %[[#bb128]] = OpLabel
111 ; CHECK: OpLoopMerge %[[#bb129:]] %[[#bb130:]] None
112 ; CHECK: OpBranch %[[#bb131:]]
113 ; CHECK: %[[#bb131]] = OpLabel
114 ; CHECK: OpSelectionMerge %[[#bb132:]] None
115 ; CHECK: OpBranchConditional %[[#]] %[[#bb133:]] %[[#bb134:]]
116 ; CHECK: %[[#bb134]] = OpLabel
117 ; CHECK: OpBranch %[[#bb132]]
118 ; CHECK: %[[#bb133]] = OpLabel
119 ; CHECK: OpBranch %[[#bb132]]
120 ; CHECK: %[[#bb132]] = OpLabel
121 ; CHECK: OpBranchConditional %[[#]] %[[#bb130]] %[[#bb129]]
122 ; CHECK: %[[#bb129]] = OpLabel
123 ; CHECK: OpReturn
124 ; CHECK: %[[#bb130]] = OpLabel
125 ; CHECK: OpBranch %[[#bb128]]
126 ; CHECK: %[[#bb123]] = OpLabel
127 ; CHECK: OpBranch %[[#bb121]]
128 ; CHECK: %[[#bb104]] = OpLabel
129 ; CHECK: OpBranch %[[#bb102]]
130 ; CHECK: %[[#bb97]] = OpLabel
131 ; CHECK: OpBranch %[[#bb95]]
132 ; CHECK: %[[#bb90]] = OpLabel
133 ; CHECK: OpBranch %[[#bb88]]
134 ; CHECK: OpFunctionEnd
135
136 ; CHECK: %[[#func_85:]] = OpFunction %[[#void]] None %[[#]]
137 ; CHECK: %[[#bb135:]] = OpLabel
138 ; CHECK: OpReturn
139 ; CHECK: OpFunctionEnd
140
141 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
142 target triple = "spirv-unknown-vulkan1.3-compute"
143
144 ; Function Attrs: convergent noinline norecurse nounwind optnone
145 define internal spir_func void @main() #0 {
146 entry:
147 %0 = call token @llvm.experimental.convergence.entry()
148 %a = alloca i32, align 4
149 %b = alloca i32, align 4
150 %x = alloca i32, align 4
151 %y = alloca i32, align 4
152 br label %while.cond
153
154 while.cond: ; preds = %while.body, %entry
155 %1 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
156 %2 = load i32, ptr %a, align 4
157 %tobool = icmp ne i32 %2, 0
158 br i1 %tobool, label %land.rhs, label %land.end
159
160 land.rhs: ; preds = %while.cond
161 %3 = load i32, ptr %b, align 4
162 %tobool1 = icmp ne i32 %3, 0
163 br label %land.end
164
165 land.end: ; preds = %land.rhs, %while.cond
166 %4 = phi i1 [ false, %while.cond ], [ %tobool1, %land.rhs ]
167 br i1 %4, label %while.body, label %while.end
168
169 while.body: ; preds = %land.end
170 br label %while.cond
171
172 while.end: ; preds = %land.end
173 br label %while.cond2
174
175 while.cond2: ; preds = %while.body5, %while.end
176 %5 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
177 %6 = load i32, ptr %a, align 4
178 %tobool3 = icmp ne i32 %6, 0
179 br i1 %tobool3, label %lor.end, label %lor.rhs
180
181 lor.rhs: ; preds = %while.cond2
182 %7 = load i32, ptr %b, align 4
183 %tobool4 = icmp ne i32 %7, 0
184 br label %lor.end
185
186 lor.end: ; preds = %lor.rhs, %while.cond2
187 %8 = phi i1 [ true, %while.cond2 ], [ %tobool4, %lor.rhs ]
188 br i1 %8, label %while.body5, label %while.end6
189
190 while.body5: ; preds = %lor.end
191 br label %while.cond2
192
193 while.end6: ; preds = %lor.end
194 br label %while.cond7
195
196 while.cond7: ; preds = %while.body16, %while.end6
197 %9 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
198 %10 = load i32, ptr %a, align 4
199 %tobool8 = icmp ne i32 %10, 0
200 br i1 %tobool8, label %land.rhs9, label %land.end15
201
202 land.rhs9: ; preds = %while.cond7
203 %11 = load i32, ptr %a, align 4
204 %tobool10 = icmp ne i32 %11, 0
205 br i1 %tobool10, label %land.rhs12, label %lor.lhs.false
206
207 lor.lhs.false: ; preds = %land.rhs9
208 %12 = load i32, ptr %b, align 4
209 %tobool11 = icmp ne i32 %12, 0
210 br i1 %tobool11, label %land.rhs12, label %land.end14
211
212 land.rhs12: ; preds = %lor.lhs.false, %land.rhs9
213 %13 = load i32, ptr %b, align 4
214 %tobool13 = icmp ne i32 %13, 0
215 br label %land.end14
216
217 land.end14: ; preds = %land.rhs12, %lor.lhs.false
218 %14 = phi i1 [ false, %lor.lhs.false ], [ %tobool13, %land.rhs12 ]
219 br label %land.end15
220
221 land.end15: ; preds = %land.end14, %while.cond7
222 %15 = phi i1 [ false, %while.cond7 ], [ %14, %land.end14 ]
223 br i1 %15, label %while.body16, label %while.end17
224
225 while.body16: ; preds = %land.end15
226 br label %while.cond7
227
228 while.end17: ; preds = %land.end15
229 br label %while.cond18
230
231 while.cond18: ; preds = %while.body21, %while.end17
232 %16 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
233 %17 = load i32, ptr %a, align 4
234 %tobool19 = icmp ne i32 %17, 0
235 br i1 %tobool19, label %cond.true, label %cond.false
236
237 cond.true: ; preds = %while.cond18
238 %18 = load i32, ptr %a, align 4
239 br label %cond.end
240
241 cond.false: ; preds = %while.cond18
242 %19 = load i32, ptr %b, align 4
243 br label %cond.end
244
245 cond.end: ; preds = %cond.false, %cond.true
246 %cond = phi i32 [ %18, %cond.true ], [ %19, %cond.false ]
247 %tobool20 = icmp ne i32 %cond, 0
248 br i1 %tobool20, label %while.body21, label %while.end22
249
250 while.body21: ; preds = %cond.end
251 br label %while.cond18
252
253 while.end22: ; preds = %cond.end
254 br label %while.cond23
255
256 while.cond23: ; preds = %while.body29, %while.end22
257 %20 = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %0) ]
258 %21 = load i32, ptr %x, align 4
259 %22 = load i32, ptr %x, align 4
260 %tobool24 = icmp ne i32 %22, 0
261 br i1 %tobool24, label %land.rhs25, label %land.end27
262
263 land.rhs25: ; preds = %while.cond23
264 %23 = load i32, ptr %y, align 4
265 %tobool26 = icmp ne i32 %23, 0
266 br label %land.end27
267
268 land.end27: ; preds = %land.rhs25, %while.cond23
269 %24 = phi i1 [ false, %while.cond23 ], [ %tobool26, %land.rhs25 ]
270 %conv = zext i1 %24 to i32
271 %add = add nsw i32 %21, %conv
272 %tobool28 = icmp ne i32 %add, 0
273 br i1 %tobool28, label %while.body29, label %while.end30
274
275 while.body29: ; preds = %land.end27
276 br label %while.cond23
277
278 while.end30: ; preds = %land.end27
279 ret void
280 }
281
282 ; Function Attrs: convergent norecurse
283 define void @main.1() #1 {
284 entry:
285 call void @main()
286 ret void
287 }
288
289 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
290 declare token @llvm.experimental.convergence.entry() #2
291
292 ; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
293 declare token @llvm.experimental.convergence.loop() #2
294
295 attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
296 attributes #1 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
297 attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
298
299 !llvm.module.flags = !{!0, !1, !2}
300
301
302 !0 = !{i32 1, !"wchar_size", i32 4}
303 !1 = !{i32 4, !"dx.disable_optimizations", i32 1}
304 !2 = !{i32 7, !"frame-pointer", i32 2}
305
306