• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -callsite-splitting -S | FileCheck %s
2; RUN: opt < %s  -passes='function(callsite-splitting)' -S | FileCheck %s
3
4target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5target triple = "aarch64-linaro-linux-gnueabi"
6
7;CHECK-LABEL: @test_eq_eq
8
9;CHECK-LABEL: Header:
10;CHECK: br i1 %tobool1, label %Header.split, label %TBB
11;CHECK-LABEL: Header.split:
12;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 1)
13;CHECK-LABEL: TBB:
14;CHECK: br i1 %cmp, label %TBB.split, label %End
15;CHECK-LABEL: TBB.split:
16;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 2)
17;CHECK-LABEL: Tail
18;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
19;CHECK: ret i32 %[[MERGED]]
20define i32 @test_eq_eq(i32* %a, i32 %v) {
21Header:
22  %tobool1 = icmp eq i32* %a, null
23  br i1 %tobool1, label %Tail, label %TBB
24
25TBB:
26  %cmp = icmp eq i32 %v, 1
27  br i1 %cmp, label %Tail, label %End
28
29Tail:
30  %p = phi i32[1,%Header], [2, %TBB]
31  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
32  ret i32 %r
33
34End:
35  ret i32 %v
36}
37
38;CHECK-LABEL: @test_eq_eq_eq
39;CHECK-LABEL: Header2.split:
40;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 10)
41;CHECK-LABEL: TBB.split:
42;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 %p)
43;CHECK-LABEL: Tail
44;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header2.split ], [ %[[CALL2]], %TBB.split ]
45;CHECK: ret i32 %[[MERGED]]
46define i32 @test_eq_eq_eq(i32* %a, i32 %v, i32 %p) {
47Header:
48  %tobool1 = icmp eq i32* %a, null
49  br i1 %tobool1, label %Header2, label %End
50
51Header2:
52  %tobool2 = icmp eq i32 %p, 10
53  br i1 %tobool2, label %Tail, label %TBB
54
55TBB:
56  %cmp = icmp eq i32 %v, 1
57  br i1 %cmp, label %Tail, label %End
58
59Tail:
60  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
61  ret i32 %r
62
63End:
64  ret i32 %v
65}
66
67;CHECK-LABEL: @test_eq_eq_eq_constrain_same_i32_arg
68;CHECK-LABEL: Header2.split:
69;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 222, i32 %p)
70;CHECK-LABEL: TBB.split:
71;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 333, i32 %p)
72;CHECK-LABEL: Tail
73;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header2.split ], [ %[[CALL2]], %TBB.split ]
74;CHECK: ret i32 %[[MERGED]]
75define i32 @test_eq_eq_eq_constrain_same_i32_arg(i32* %a, i32 %v, i32 %p) {
76Header:
77  %tobool1 = icmp eq i32 %v, 111
78  br i1 %tobool1, label %Header2, label %End
79
80Header2:
81  %tobool2 = icmp eq i32 %v, 222
82  br i1 %tobool2, label %Tail, label %TBB
83
84TBB:
85  %cmp = icmp eq i32 %v, 333
86  br i1 %cmp, label %Tail, label %End
87
88Tail:
89  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
90  ret i32 %r
91
92End:
93  ret i32 %v
94}
95
96;CHECK-LABEL: @test_ne_eq
97;CHECK-LABEL: Header.split:
98;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 1)
99;CHECK-LABEL: TBB.split:
100;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 1, i32 2)
101;CHECK-LABEL: Tail
102;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
103;CHECK: ret i32 %[[MERGED]]
104define i32 @test_ne_eq(i32* %a, i32 %v) {
105Header:
106  %tobool1 = icmp ne i32* %a, null
107  br i1 %tobool1, label %Tail, label %TBB
108
109TBB:
110  %cmp = icmp eq i32 %v, 1
111  br i1 %cmp, label %Tail, label %End
112
113Tail:
114  %p = phi i32[1,%Header], [2, %TBB]
115  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
116  ret i32 %r
117
118End:
119  ret i32 %v
120}
121
122;CHECK-LABEL: @test_ne_eq_ne
123;CHECK-LABEL: Header2.split:
124;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 10)
125;CHECK-LABEL: TBB.split:
126;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 %p)
127;CHECK-LABEL: Tail
128;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header2.split ], [ %[[CALL2]], %TBB.split ]
129;CHECK: ret i32 %[[MERGED]]
130define i32 @test_ne_eq_ne(i32* %a, i32 %v, i32 %p) {
131Header:
132  %tobool1 = icmp ne i32* %a, null
133  br i1 %tobool1, label %Header2, label %TBB
134
135Header2:
136  %tobool2 = icmp eq i32 %p, 10
137  br i1 %tobool2, label %Tail, label %TBB
138
139TBB:
140  %cmp = icmp ne i32 %v, 1
141  br i1 %cmp, label %Tail, label %End
142
143Tail:
144  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
145  ret i32 %r
146
147End:
148  ret i32 %v
149}
150
151;CHECK-LABEL: @test_ne_ne
152;CHECK-LABEL: Header.split:
153;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 1)
154;CHECK-LABEL: TBB.split:
155;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 %v, i32 2)
156;CHECK-LABEL: Tail
157;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
158;CHECK: ret i32 %[[MERGED]]
159define i32 @test_ne_ne(i32* %a, i32 %v) {
160Header:
161  %tobool1 = icmp ne i32* %a, null
162  br i1 %tobool1, label %Tail, label %TBB
163
164TBB:
165  %cmp = icmp ne i32 %v, 1
166  br i1 %cmp, label %Tail, label %End
167
168Tail:
169  %p = phi i32[1,%Header], [2, %TBB]
170  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
171  ret i32 %r
172
173End:
174  ret i32 %v
175}
176
177;CHECK-LABEL: @test_ne_ne_ne_constrain_same_pointer_arg
178;CHECK-LABEL: Header2.split:
179;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 %p)
180;CHECK-LABEL: TBB.split:
181;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 %p)
182;CHECK-LABEL: Tail
183;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header2.split ], [ %[[CALL2]], %TBB.split ]
184;CHECK: ret i32 %[[MERGED]]
185define i32 @test_ne_ne_ne_constrain_same_pointer_arg(i32* %a, i32 %v, i32 %p, i32* %a2, i32* %a3) {
186Header:
187  %tobool1 = icmp ne i32* %a, null
188  br i1 %tobool1, label %Header2, label %TBB
189
190Header2:
191  %tobool2 = icmp ne i32* %a, %a2
192  br i1 %tobool2, label %Tail, label %TBB
193
194TBB:
195  %cmp = icmp ne i32* %a, %a3
196  br i1 %cmp, label %Tail, label %End
197
198Tail:
199  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
200  ret i32 %r
201
202End:
203  ret i32 %v
204}
205
206
207
208;CHECK-LABEL: @test_eq_eq_untaken
209;CHECK-LABEL: Header.split:
210;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 1)
211;CHECK-LABEL: TBB.split:
212;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 1, i32 2)
213;CHECK-LABEL: Tail
214;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
215;CHECK: ret i32 %[[MERGED]]
216define i32 @test_eq_eq_untaken(i32* %a, i32 %v) {
217Header:
218  %tobool1 = icmp eq i32* %a, null
219  br i1 %tobool1, label %TBB, label %Tail
220
221TBB:
222  %cmp = icmp eq i32 %v, 1
223  br i1 %cmp, label %Tail, label %End
224
225Tail:
226  %p = phi i32[1,%Header], [2, %TBB]
227  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
228  ret i32 %r
229
230End:
231  ret i32 %v
232}
233
234;CHECK-LABEL: @test_eq_eq_eq_untaken
235;CHECK-LABEL: Header2.split:
236;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 10)
237;CHECK-LABEL: TBB.split:
238;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 %p)
239;CHECK-LABEL: Tail
240;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header2.split ], [ %[[CALL2]], %TBB.split ]
241;CHECK: ret i32 %[[MERGED]]
242define i32 @test_eq_eq_eq_untaken(i32* %a, i32 %v, i32 %p) {
243Header:
244  %tobool1 = icmp eq i32* %a, null
245  br i1 %tobool1, label %TBB, label %Header2
246
247Header2:
248  %tobool2 = icmp eq i32 %p, 10
249  br i1 %tobool2, label %Tail, label %TBB
250
251TBB:
252  %cmp = icmp eq i32 %v, 1
253  br i1 %cmp, label %Tail, label %End
254
255Tail:
256  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
257  ret i32 %r
258
259End:
260  ret i32 %v
261}
262
263;CHECK-LABEL: @test_ne_eq_untaken
264;CHECK-LABEL: Header.split:
265;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 1)
266;CHECK-LABEL: TBB.split:
267;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 2)
268;CHECK-LABEL: Tail
269;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
270;CHECK: ret i32 %[[MERGED]]
271define i32 @test_ne_eq_untaken(i32* %a, i32 %v) {
272Header:
273  %tobool1 = icmp ne i32* %a, null
274  br i1 %tobool1, label %TBB, label %Tail
275
276TBB:
277  %cmp = icmp eq i32 %v, 1
278  br i1 %cmp, label %Tail, label %End
279
280Tail:
281  %p = phi i32[1,%Header], [2, %TBB]
282  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
283  ret i32 %r
284
285End:
286  ret i32 %v
287}
288
289;CHECK-LABEL: @test_ne_eq_ne_untaken
290;CHECK-LABEL: Header2.split:
291;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 10)
292;CHECK-LABEL: TBB.split:
293;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 %p)
294;CHECK-LABEL: Tail
295;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header2.split ], [ %[[CALL2]], %TBB.split ]
296;CHECK: ret i32 %[[MERGED]]
297define i32 @test_ne_eq_ne_untaken(i32* %a, i32 %v, i32 %p) {
298Header:
299  %tobool1 = icmp ne i32* %a, null
300  br i1 %tobool1, label %TBB, label %Header2
301
302Header2:
303  %tobool2 = icmp eq i32 %p, 10
304  br i1 %tobool2, label %Tail, label %TBB
305
306TBB:
307  %cmp = icmp ne i32 %v, 1
308  br i1 %cmp, label %Tail, label %End
309
310Tail:
311  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
312  ret i32 %r
313
314End:
315  ret i32 %v
316}
317
318;CHECK-LABEL: @test_ne_ne_untaken
319;CHECK-LABEL: Header.split:
320;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 1)
321;CHECK-LABEL: TBB.split:
322;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 2)
323;CHECK-LABEL: Tail
324;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
325;CHECK: ret i32 %[[MERGED]]
326define i32 @test_ne_ne_untaken(i32* %a, i32 %v) {
327Header:
328  %tobool1 = icmp ne i32* %a, null
329  br i1 %tobool1, label %TBB, label %Tail
330
331TBB:
332  %cmp = icmp ne i32 %v, 1
333  br i1 %cmp, label %End, label %Tail
334
335Tail:
336  %p = phi i32[1,%Header], [2, %TBB]
337  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
338  ret i32 %r
339
340End:
341  ret i32 %v
342}
343
344;CHECK-LABEL: @test_nonconst_const_phi
345;CHECK-LABEL: Header.split:
346;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 1)
347;CHECK-LABEL: TBB.split:
348;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 2)
349;CHECK-LABEL: Tail
350;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
351;CHECK: ret i32 %[[MERGED]]
352define i32 @test_nonconst_const_phi(i32* %a, i32* %b, i32 %v) {
353Header:
354  %tobool1 = icmp eq i32* %a, %b
355  br i1 %tobool1, label %Tail, label %TBB
356
357TBB:
358  %cmp = icmp eq i32 %v, 1
359  br i1 %cmp, label %Tail, label %End
360
361Tail:
362  %p = phi i32[1,%Header], [2, %TBB]
363  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
364  ret i32 %r
365
366End:
367  ret i32 %v
368}
369
370;CHECK-LABEL: @test_nonconst_nonconst_phi
371;CHECK-LABEL: Header.split:
372;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 1)
373;CHECK-LABEL: TBB.split:
374;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 2)
375;CHECK-LABEL: Tail
376;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL2]], %TBB.split ], [ %[[CALL1]], %Header.split ]
377;CHECK: ret i32 %[[MERGED]]
378define i32 @test_nonconst_nonconst_phi(i32* %a, i32* %b, i32 %v, i32 %v2) {
379Header:
380  %tobool1 = icmp eq i32* %a, %b
381  br i1 %tobool1, label %Tail, label %TBB
382
383TBB:
384  %cmp = icmp eq i32 %v, %v2
385  br i1 %cmp, label %Tail, label %End
386
387Tail:
388  %p = phi i32[1,%Header], [2, %TBB]
389  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
390  ret i32 %r
391
392End:
393  ret i32 %v
394}
395
396;CHECK-LABEL: @test_cfg_no_or_phi
397;CHECK-LABEL: TBB0.split
398;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 1)
399;CHECK-LABEL: TBB1.split:
400;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 2)
401;CHECK-LABEL: Tail
402;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL2]], %TBB1.split ], [ %[[CALL1]], %TBB0.split ]
403;CHECK: ret i32 %[[MERGED]]
404define i32 @test_cfg_no_or_phi(i32* %a,  i32 %v) {
405entry:
406  br i1 undef, label %TBB0, label %TBB1
407TBB0:
408  br i1 undef, label %Tail, label %End
409TBB1:
410  br i1 undef, label %Tail, label %End
411Tail:
412  %p = phi i32[1,%TBB0], [2, %TBB1]
413  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
414  ret i32 %r
415End:
416  ret i32 %v
417}
418
419;CHECK-LABEL: @test_nonconst_nonconst_phi_noncost
420;CHECK-NOT: Header.split:
421;CHECK-NOT: TBB.split:
422;CHECK-LABEL: Tail:
423;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
424;CHECK: ret i32 %r
425define i32 @test_nonconst_nonconst_phi_noncost(i32* %a, i32* %b, i32 %v, i32 %v2) {
426Header:
427  %tobool1 = icmp eq i32* %a, %b
428  br i1 %tobool1, label %Tail, label %TBB
429
430TBB:
431  %cmp = icmp eq i32 %v, %v2
432  br i1 %cmp, label %Tail, label %End
433
434Tail:
435  %p = phi i32[%v,%Header], [%v2, %TBB]
436  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
437  ret i32 %r
438
439End:
440  ret i32 %v
441}
442
443;CHECK-LABEL: @test_3preds_constphi
444;CHECK-NOT: Header.split:
445;CHECK-NOT: TBB.split:
446;CHECK-LABEL: Tail:
447;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
448;CHECK: ret i32 %r
449define i32 @test_3preds_constphi(i32* %a, i32 %v, i1 %c1, i1 %c2, i1 %c3) {
450Header:
451  br i1 %c1, label %Tail, label %TBB1
452
453TBB1:
454  br i1 %c2, label %Tail, label %TBB2
455
456TBB2:
457  br i1 %c3, label %Tail, label %End
458
459Tail:
460  %p = phi i32[1,%Header], [2, %TBB1], [3, %TBB2]
461  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
462  ret i32 %r
463
464End:
465  ret i32 %v
466}
467
468;CHECK-LABEL: @test_indirectbr_phi
469;CHECK-NOT: Header.split:
470;CHECK-NOT: TBB.split:
471;CHECK-LABEL: Tail:
472;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
473;CHECK: ret i32 %r
474define i32 @test_indirectbr_phi(i8* %address, i32* %a, i32* %b, i32 %v) {
475Header:
476   %indirect.goto.dest = select i1 undef, i8* blockaddress(@test_indirectbr_phi, %End), i8* %address
477   indirectbr i8* %indirect.goto.dest, [label %TBB, label %Tail]
478
479TBB:
480  %indirect.goto.dest2 = select i1 undef, i8* blockaddress(@test_indirectbr_phi, %End), i8* %address
481  indirectbr i8* %indirect.goto.dest2, [label %Tail, label %End]
482
483Tail:
484  %p = phi i32[1,%Header], [2, %TBB]
485  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
486  ret i32 %r
487
488End:
489  ret i32 %v
490}
491
492;CHECK-LABEL: @test_cond_no_effect
493;CHECK-NOT: Header.split:
494;CHECK-NOT: TBB.split:
495;CHECK-LABEL: Tail:
496;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 0)
497;CHECK: ret i32 %r
498define i32 @test_cond_no_effect(i32* %a, i32 %v) {
499Entry:
500  %tobool1 = icmp eq i32* %a, null
501  br i1 %tobool1, label %Header, label %End
502
503Header:
504  br i1 undef, label %Tail, label %TBB
505
506TBB:
507  br i1 undef, label %Tail, label %End
508
509Tail:
510  %r = call i32 @callee(i32* %a, i32 %v, i32 0)
511  ret i32 %r
512
513End:
514  ret i32 %v
515}
516
517;CHECK-LABEL: @test_unreachable
518;CHECK-LABEL: Header.split:
519;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 10)
520;CHECK-LABEL: TBB.split:
521;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 %p)
522;CHECK-LABEL: Tail
523;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Header.split ], [ %[[CALL2]], %TBB.split ]
524;CHECK: ret i32 %[[MERGED]]
525define i32 @test_unreachable(i32* %a, i32 %v, i32 %p) {
526Entry:
527  br label %End
528Header:
529  %tobool2 = icmp eq i32 %p, 10
530  br i1 %tobool2, label %Tail, label %TBB
531TBB:
532  %cmp = icmp eq i32 %v, 1
533  br i1 %cmp, label %Tail, label %Header
534Tail:
535  %r = call i32 @callee(i32* %a, i32 %v, i32 %p)
536  ret i32 %r
537End:
538  ret i32 %v
539}
540
541define i32 @callee(i32* %a, i32 %v, i32 %p) {
542entry:
543  %c = icmp ne i32* %a, null
544  br i1 %c, label %BB1, label %BB2
545
546BB1:
547  call void @dummy(i32* %a, i32 %p)
548  br label %End
549
550BB2:
551  call void @dummy2(i32 %v, i32 %p)
552  br label %End
553
554End:
555  ret i32 %p
556}
557
558declare void @dummy(i32*, i32)
559declare void @dummy2(i32, i32)
560
561; Make sure we remove the non-nullness on constant paramater.
562;
563;CHECK-LABEL: @caller2
564;CHECK-LABEL: Top1.split:
565;CHECK: call i32 @callee(i32* inttoptr (i64 4643 to i32*)
566define void @caller2(i32 %c, i32* %a_elt, i32* %b_elt) {
567entry:
568  br label %Top0
569
570Top0:
571  %tobool1 = icmp eq i32* %a_elt, inttoptr (i64 4643 to  i32*)
572  br i1 %tobool1, label %Top1, label %NextCond
573
574Top1:
575  %tobool2 = icmp ne i32* %a_elt, null
576  br i1 %tobool2, label %CallSiteBB, label %NextCond
577
578NextCond:
579  %cmp = icmp ne i32* %b_elt, null
580  br i1 %cmp, label %CallSiteBB, label %End
581
582CallSiteBB:
583  call i32 @callee(i32* %a_elt, i32 %c, i32 %c)
584  br label %End
585
586End:
587  ret void
588}
589
590; CHECK-LABEL: i32 @test_multiple_phis(
591; CHECK:      Header.split:
592; CHECK-NEXT:   %r2 = call i32 @callee(i32* null, i32 1, i32 5)
593; CHECK-NEXT:   br label %Tail
594
595; CHECK:      TBB.split:
596; CHECK-NEXT:   %r1 = call i32 @callee(i32* null, i32 2, i32 10)
597; CHECK-NEXT:   br label %Tail
598
599; CHECK:        Tail:
600; CHECK-NEXT:   %phi.call = phi i32 [ %r1, %TBB.split ], [ %r2, %Header.split ]
601; CHECK-NEXT:   %p.0 = phi i32 [ 0, %Header.split ], [ 99, %TBB.split ]
602; CHECK-NEXT:   %res = add i32 %phi.call, %p.0
603; CHECK-NEXT:   ret i32 %phi.call
604;
605define i32 @test_multiple_phis(i1 %c.1) {
606Header:
607  br i1 %c.1, label %Tail, label %TBB
608
609TBB:
610  br label %Tail
611
612Tail:
613  %p.0 = phi i32 [0, %Header], [99, %TBB]
614  %p.1 = phi i32[1, %Header], [2, %TBB]
615  %p.2 = phi i32 [5, %Header], [10, %TBB]
616  %r = call i32 @callee(i32* null, i32 %p.1, i32 %p.2)
617  %res = add i32 %r, %p.0
618  ret i32 %r
619
620End:
621  ret i32 10
622}
623