with-parent-loops.ll
14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
; RUN: opt -verify-loop-info -irce-print-changed-loops -irce < %s 2>&1 | FileCheck %s
; RUN: opt -verify-loop-info -irce-print-changed-loops -passes='require<branch-prob>,loop(irce)' < %s 2>&1 | FileCheck %s
; This test checks if we update the LoopInfo correctly in the presence
; of parents, uncles and cousins.
; Function Attrs: alwaysinline
define void @inner_loop(i32* %arr, i32* %a_len_ptr, i32 %n) #0 {
; CHECK: irce: in function inner_loop: constrained Loop at depth 1 containing: %loop<header><exiting>,%in.bounds<latch><exiting>
entry:
%len = load i32, i32* %a_len_ptr, !range !0
%first.itr.check = icmp sgt i32 %n, 0
br i1 %first.itr.check, label %loop, label %exit
loop: ; preds = %in.bounds, %entry
%idx = phi i32 [ 0, %entry ], [ %idx.next, %in.bounds ]
%idx.next = add i32 %idx, 1
%abc = icmp slt i32 %idx, %len
br i1 %abc, label %in.bounds, label %out.of.bounds, !prof !1
in.bounds: ; preds = %loop
%addr = getelementptr i32, i32* %arr, i32 %idx
store i32 0, i32* %addr
%next = icmp slt i32 %idx.next, %n
br i1 %next, label %loop, label %exit
out.of.bounds: ; preds = %loop
ret void
exit: ; preds = %in.bounds, %entry
ret void
}
; Function Attrs: alwaysinline
define void @with_parent(i32* %arr, i32* %a_len_ptr, i32 %n, i32 %parent.count) #0 {
; CHECK: irce: in function with_parent: constrained Loop at depth 2 containing: %loop.i<header><exiting>,%in.bounds.i<latch><exiting>
entry:
br label %loop
loop: ; preds = %inner_loop.exit, %entry
%idx = phi i32 [ 0, %entry ], [ %idx.next, %inner_loop.exit ]
%idx.next = add i32 %idx, 1
%next = icmp ult i32 %idx.next, %parent.count
%len.i = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i = icmp sgt i32 %n, 0
br i1 %first.itr.check.i, label %loop.i, label %exit.i
loop.i: ; preds = %in.bounds.i, %loop
%idx.i = phi i32 [ 0, %loop ], [ %idx.next.i, %in.bounds.i ]
%idx.next.i = add i32 %idx.i, 1
%abc.i = icmp slt i32 %idx.i, %len.i
br i1 %abc.i, label %in.bounds.i, label %out.of.bounds.i, !prof !1
in.bounds.i: ; preds = %loop.i
%addr.i = getelementptr i32, i32* %arr, i32 %idx.i
store i32 0, i32* %addr.i
%next.i = icmp slt i32 %idx.next.i, %n
br i1 %next.i, label %loop.i, label %exit.i
out.of.bounds.i: ; preds = %loop.i
br label %inner_loop.exit
exit.i: ; preds = %in.bounds.i, %loop
br label %inner_loop.exit
inner_loop.exit: ; preds = %exit.i, %out.of.bounds.i
br i1 %next, label %loop, label %exit
exit: ; preds = %inner_loop.exit
ret void
}
; Function Attrs: alwaysinline
define void @with_grandparent(i32* %arr, i32* %a_len_ptr, i32 %n, i32 %parent.count, i32 %grandparent.count) #0 {
; CHECK: irce: in function with_grandparent: constrained Loop at depth 3 containing: %loop.i.i<header><exiting>,%in.bounds.i.i<latch><exiting>
entry:
br label %loop
loop: ; preds = %with_parent.exit, %entry
%idx = phi i32 [ 0, %entry ], [ %idx.next, %with_parent.exit ]
%idx.next = add i32 %idx, 1
%next = icmp ult i32 %idx.next, %grandparent.count
br label %loop.i
loop.i: ; preds = %inner_loop.exit.i, %loop
%idx.i = phi i32 [ 0, %loop ], [ %idx.next.i, %inner_loop.exit.i ]
%idx.next.i = add i32 %idx.i, 1
%next.i = icmp ult i32 %idx.next.i, %parent.count
%len.i.i = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i.i = icmp sgt i32 %n, 0
br i1 %first.itr.check.i.i, label %loop.i.i, label %exit.i.i
loop.i.i: ; preds = %in.bounds.i.i, %loop.i
%idx.i.i = phi i32 [ 0, %loop.i ], [ %idx.next.i.i, %in.bounds.i.i ]
%idx.next.i.i = add i32 %idx.i.i, 1
%abc.i.i = icmp slt i32 %idx.i.i, %len.i.i
br i1 %abc.i.i, label %in.bounds.i.i, label %out.of.bounds.i.i, !prof !1
in.bounds.i.i: ; preds = %loop.i.i
%addr.i.i = getelementptr i32, i32* %arr, i32 %idx.i.i
store i32 0, i32* %addr.i.i
%next.i.i = icmp slt i32 %idx.next.i.i, %n
br i1 %next.i.i, label %loop.i.i, label %exit.i.i
out.of.bounds.i.i: ; preds = %loop.i.i
br label %inner_loop.exit.i
exit.i.i: ; preds = %in.bounds.i.i, %loop.i
br label %inner_loop.exit.i
inner_loop.exit.i: ; preds = %exit.i.i, %out.of.bounds.i.i
br i1 %next.i, label %loop.i, label %with_parent.exit
with_parent.exit: ; preds = %inner_loop.exit.i
br i1 %next, label %loop, label %exit
exit: ; preds = %with_parent.exit
ret void
}
; Function Attrs: alwaysinline
define void @with_sibling(i32* %arr, i32* %a_len_ptr, i32 %n, i32 %parent.count) #0 {
; CHECK: irce: in function with_sibling: constrained Loop at depth 2 containing: %loop.i<header><exiting>,%in.bounds.i<latch><exiting>
; CHECK: irce: in function with_sibling: constrained Loop at depth 2 containing: %loop.i6<header><exiting>,%in.bounds.i9<latch><exiting>
entry:
br label %loop
loop: ; preds = %inner_loop.exit12, %entry
%idx = phi i32 [ 0, %entry ], [ %idx.next, %inner_loop.exit12 ]
%idx.next = add i32 %idx, 1
%next = icmp ult i32 %idx.next, %parent.count
%len.i = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i = icmp sgt i32 %n, 0
br i1 %first.itr.check.i, label %loop.i, label %exit.i
loop.i: ; preds = %in.bounds.i, %loop
%idx.i = phi i32 [ 0, %loop ], [ %idx.next.i, %in.bounds.i ]
%idx.next.i = add i32 %idx.i, 1
%abc.i = icmp slt i32 %idx.i, %len.i
br i1 %abc.i, label %in.bounds.i, label %out.of.bounds.i, !prof !1
in.bounds.i: ; preds = %loop.i
%addr.i = getelementptr i32, i32* %arr, i32 %idx.i
store i32 0, i32* %addr.i
%next.i = icmp slt i32 %idx.next.i, %n
br i1 %next.i, label %loop.i, label %exit.i
out.of.bounds.i: ; preds = %loop.i
br label %inner_loop.exit
exit.i: ; preds = %in.bounds.i, %loop
br label %inner_loop.exit
inner_loop.exit: ; preds = %exit.i, %out.of.bounds.i
%len.i1 = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i2 = icmp sgt i32 %n, 0
br i1 %first.itr.check.i2, label %loop.i6, label %exit.i11
loop.i6: ; preds = %in.bounds.i9, %inner_loop.exit
%idx.i3 = phi i32 [ 0, %inner_loop.exit ], [ %idx.next.i4, %in.bounds.i9 ]
%idx.next.i4 = add i32 %idx.i3, 1
%abc.i5 = icmp slt i32 %idx.i3, %len.i1
br i1 %abc.i5, label %in.bounds.i9, label %out.of.bounds.i10, !prof !1
in.bounds.i9: ; preds = %loop.i6
%addr.i7 = getelementptr i32, i32* %arr, i32 %idx.i3
store i32 0, i32* %addr.i7
%next.i8 = icmp slt i32 %idx.next.i4, %n
br i1 %next.i8, label %loop.i6, label %exit.i11
out.of.bounds.i10: ; preds = %loop.i6
br label %inner_loop.exit12
exit.i11: ; preds = %in.bounds.i9, %inner_loop.exit
br label %inner_loop.exit12
inner_loop.exit12: ; preds = %exit.i11, %out.of.bounds.i10
br i1 %next, label %loop, label %exit
exit: ; preds = %inner_loop.exit12
ret void
}
; Function Attrs: alwaysinline
define void @with_cousin(i32* %arr, i32* %a_len_ptr, i32 %n, i32 %parent.count, i32 %grandparent.count) #0 {
; CHECK: irce: in function with_cousin: constrained Loop at depth 3 containing: %loop.i.i<header><exiting>,%in.bounds.i.i<latch><exiting>
; CHECK: irce: in function with_cousin: constrained Loop at depth 3 containing: %loop.i.i10<header><exiting>,%in.bounds.i.i13<latch><exiting>
entry:
br label %loop
loop: ; preds = %with_parent.exit17, %entry
%idx = phi i32 [ 0, %entry ], [ %idx.next, %with_parent.exit17 ]
%idx.next = add i32 %idx, 1
%next = icmp ult i32 %idx.next, %grandparent.count
br label %loop.i
loop.i: ; preds = %inner_loop.exit.i, %loop
%idx.i = phi i32 [ 0, %loop ], [ %idx.next.i, %inner_loop.exit.i ]
%idx.next.i = add i32 %idx.i, 1
%next.i = icmp ult i32 %idx.next.i, %parent.count
%len.i.i = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i.i = icmp sgt i32 %n, 0
br i1 %first.itr.check.i.i, label %loop.i.i, label %exit.i.i
loop.i.i: ; preds = %in.bounds.i.i, %loop.i
%idx.i.i = phi i32 [ 0, %loop.i ], [ %idx.next.i.i, %in.bounds.i.i ]
%idx.next.i.i = add i32 %idx.i.i, 1
%abc.i.i = icmp slt i32 %idx.i.i, %len.i.i
br i1 %abc.i.i, label %in.bounds.i.i, label %out.of.bounds.i.i, !prof !1
in.bounds.i.i: ; preds = %loop.i.i
%addr.i.i = getelementptr i32, i32* %arr, i32 %idx.i.i
store i32 0, i32* %addr.i.i
%next.i.i = icmp slt i32 %idx.next.i.i, %n
br i1 %next.i.i, label %loop.i.i, label %exit.i.i
out.of.bounds.i.i: ; preds = %loop.i.i
br label %inner_loop.exit.i
exit.i.i: ; preds = %in.bounds.i.i, %loop.i
br label %inner_loop.exit.i
inner_loop.exit.i: ; preds = %exit.i.i, %out.of.bounds.i.i
br i1 %next.i, label %loop.i, label %with_parent.exit
with_parent.exit: ; preds = %inner_loop.exit.i
br label %loop.i6
loop.i6: ; preds = %inner_loop.exit.i16, %with_parent.exit
%idx.i1 = phi i32 [ 0, %with_parent.exit ], [ %idx.next.i2, %inner_loop.exit.i16 ]
%idx.next.i2 = add i32 %idx.i1, 1
%next.i3 = icmp ult i32 %idx.next.i2, %parent.count
%len.i.i4 = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i.i5 = icmp sgt i32 %n, 0
br i1 %first.itr.check.i.i5, label %loop.i.i10, label %exit.i.i15
loop.i.i10: ; preds = %in.bounds.i.i13, %loop.i6
%idx.i.i7 = phi i32 [ 0, %loop.i6 ], [ %idx.next.i.i8, %in.bounds.i.i13 ]
%idx.next.i.i8 = add i32 %idx.i.i7, 1
%abc.i.i9 = icmp slt i32 %idx.i.i7, %len.i.i4
br i1 %abc.i.i9, label %in.bounds.i.i13, label %out.of.bounds.i.i14, !prof !1
in.bounds.i.i13: ; preds = %loop.i.i10
%addr.i.i11 = getelementptr i32, i32* %arr, i32 %idx.i.i7
store i32 0, i32* %addr.i.i11
%next.i.i12 = icmp slt i32 %idx.next.i.i8, %n
br i1 %next.i.i12, label %loop.i.i10, label %exit.i.i15
out.of.bounds.i.i14: ; preds = %loop.i.i10
br label %inner_loop.exit.i16
exit.i.i15: ; preds = %in.bounds.i.i13, %loop.i6
br label %inner_loop.exit.i16
inner_loop.exit.i16: ; preds = %exit.i.i15, %out.of.bounds.i.i14
br i1 %next.i3, label %loop.i6, label %with_parent.exit17
with_parent.exit17: ; preds = %inner_loop.exit.i16
br i1 %next, label %loop, label %exit
exit: ; preds = %with_parent.exit17
ret void
}
; Function Attrs: alwaysinline
define void @with_uncle(i32* %arr, i32* %a_len_ptr, i32 %n, i32 %parent.count, i32 %grandparent.count) #0 {
; CHECK: irce: in function with_uncle: constrained Loop at depth 2 containing: %loop.i<header><exiting>,%in.bounds.i<latch><exiting>
; CHECK: irce: in function with_uncle: constrained Loop at depth 3 containing: %loop.i.i<header><exiting>,%in.bounds.i.i<latch><exiting>
entry:
br label %loop
loop: ; preds = %with_parent.exit, %entry
%idx = phi i32 [ 0, %entry ], [ %idx.next, %with_parent.exit ]
%idx.next = add i32 %idx, 1
%next = icmp ult i32 %idx.next, %grandparent.count
%len.i = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i = icmp sgt i32 %n, 0
br i1 %first.itr.check.i, label %loop.i, label %exit.i
loop.i: ; preds = %in.bounds.i, %loop
%idx.i = phi i32 [ 0, %loop ], [ %idx.next.i, %in.bounds.i ]
%idx.next.i = add i32 %idx.i, 1
%abc.i = icmp slt i32 %idx.i, %len.i
br i1 %abc.i, label %in.bounds.i, label %out.of.bounds.i, !prof !1
in.bounds.i: ; preds = %loop.i
%addr.i = getelementptr i32, i32* %arr, i32 %idx.i
store i32 0, i32* %addr.i
%next.i = icmp slt i32 %idx.next.i, %n
br i1 %next.i, label %loop.i, label %exit.i
out.of.bounds.i: ; preds = %loop.i
br label %inner_loop.exit
exit.i: ; preds = %in.bounds.i, %loop
br label %inner_loop.exit
inner_loop.exit: ; preds = %exit.i, %out.of.bounds.i
br label %loop.i4
loop.i4: ; preds = %inner_loop.exit.i, %inner_loop.exit
%idx.i1 = phi i32 [ 0, %inner_loop.exit ], [ %idx.next.i2, %inner_loop.exit.i ]
%idx.next.i2 = add i32 %idx.i1, 1
%next.i3 = icmp ult i32 %idx.next.i2, %parent.count
%len.i.i = load i32, i32* %a_len_ptr, !range !0
%first.itr.check.i.i = icmp sgt i32 %n, 0
br i1 %first.itr.check.i.i, label %loop.i.i, label %exit.i.i
loop.i.i: ; preds = %in.bounds.i.i, %loop.i4
%idx.i.i = phi i32 [ 0, %loop.i4 ], [ %idx.next.i.i, %in.bounds.i.i ]
%idx.next.i.i = add i32 %idx.i.i, 1
%abc.i.i = icmp slt i32 %idx.i.i, %len.i.i
br i1 %abc.i.i, label %in.bounds.i.i, label %out.of.bounds.i.i, !prof !1
in.bounds.i.i: ; preds = %loop.i.i
%addr.i.i = getelementptr i32, i32* %arr, i32 %idx.i.i
store i32 0, i32* %addr.i.i
%next.i.i = icmp slt i32 %idx.next.i.i, %n
br i1 %next.i.i, label %loop.i.i, label %exit.i.i
out.of.bounds.i.i: ; preds = %loop.i.i
br label %inner_loop.exit.i
exit.i.i: ; preds = %in.bounds.i.i, %loop.i4
br label %inner_loop.exit.i
inner_loop.exit.i: ; preds = %exit.i.i, %out.of.bounds.i.i
br i1 %next.i3, label %loop.i4, label %with_parent.exit
with_parent.exit: ; preds = %inner_loop.exit.i
br i1 %next, label %loop, label %exit
exit: ; preds = %with_parent.exit
ret void
}
attributes #0 = { alwaysinline }
!0 = !{i32 0, i32 2147483647}
!1 = !{!"branch_weights", i32 64, i32 4}