]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Analysis/BranchProbabilityInfo/basic.ll
Vendor import of llvm trunk r303571:
[FreeBSD/FreeBSD.git] / test / Analysis / BranchProbabilityInfo / basic.ll
1 ; RUN: opt < %s -analyze -branch-prob | FileCheck %s
2 ; RUN: opt < %s -analyze -lazy-branch-prob | FileCheck %s
3 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
4
5 define i32 @test1(i32 %i, i32* %a) {
6 ; CHECK: Printing analysis {{.*}} for function 'test1'
7 entry:
8   br label %body
9 ; CHECK: edge entry -> body probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
10
11 body:
12   %iv = phi i32 [ 0, %entry ], [ %next, %body ]
13   %base = phi i32 [ 0, %entry ], [ %sum, %body ]
14   %arrayidx = getelementptr inbounds i32, i32* %a, i32 %iv
15   %0 = load i32, i32* %arrayidx
16   %sum = add nsw i32 %0, %base
17   %next = add i32 %iv, 1
18   %exitcond = icmp eq i32 %next, %i
19   br i1 %exitcond, label %exit, label %body
20 ; CHECK: edge body -> exit probability is 0x04000000 / 0x80000000 = 3.12%
21 ; CHECK: edge body -> body probability is 0x7c000000 / 0x80000000 = 96.88% [HOT edge]
22
23 exit:
24   ret i32 %sum
25 }
26
27 define i32 @test2(i32 %i, i32 %a, i32 %b) {
28 ; CHECK: Printing analysis {{.*}} for function 'test2'
29 entry:
30   %cond = icmp ult i32 %i, 42
31   br i1 %cond, label %then, label %else, !prof !0
32 ; CHECK: edge entry -> then probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
33 ; CHECK: edge entry -> else probability is 0x07878788 / 0x80000000 = 5.88%
34
35 then:
36   br label %exit
37 ; CHECK: edge then -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
38
39 else:
40   br label %exit
41 ; CHECK: edge else -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
42
43 exit:
44   %result = phi i32 [ %a, %then ], [ %b, %else ]
45   ret i32 %result
46 }
47
48 !0 = !{!"branch_weights", i32 64, i32 4}
49
50 define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
51 ; CHECK: Printing analysis {{.*}} for function 'test3'
52 entry:
53   switch i32 %i, label %case_a [ i32 1, label %case_b
54                                  i32 2, label %case_c
55                                  i32 3, label %case_d
56                                  i32 4, label %case_e ], !prof !1
57 ; CHECK: edge entry -> case_a probability is 0x06666666 / 0x80000000 = 5.00%
58 ; CHECK: edge entry -> case_b probability is 0x06666666 / 0x80000000 = 5.00%
59 ; CHECK: edge entry -> case_c probability is 0x66666666 / 0x80000000 = 80.00%
60 ; CHECK: edge entry -> case_d probability is 0x06666666 / 0x80000000 = 5.00%
61 ; CHECK: edge entry -> case_e probability is 0x06666666 / 0x80000000 = 5.00%
62
63 case_a:
64   br label %exit
65 ; CHECK: edge case_a -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
66
67 case_b:
68   br label %exit
69 ; CHECK: edge case_b -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
70
71 case_c:
72   br label %exit
73 ; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
74
75 case_d:
76   br label %exit
77 ; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
78
79 case_e:
80   br label %exit
81 ; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
82
83 exit:
84   %result = phi i32 [ %a, %case_a ],
85                     [ %b, %case_b ],
86                     [ %c, %case_c ],
87                     [ %d, %case_d ],
88                     [ %e, %case_e ]
89   ret i32 %result
90 }
91
92 !1 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
93
94 define i32 @test4(i32 %x) nounwind uwtable readnone ssp {
95 ; CHECK: Printing analysis {{.*}} for function 'test4'
96 entry:
97   %conv = sext i32 %x to i64
98   switch i64 %conv, label %return [
99     i64 0, label %sw.bb
100     i64 1, label %sw.bb
101     i64 2, label %sw.bb
102     i64 5, label %sw.bb1
103   ], !prof !2
104 ; CHECK: edge entry -> return probability is 0x0a8a8a8b / 0x80000000 = 8.24%
105 ; CHECK: edge entry -> sw.bb probability is 0x15151515 / 0x80000000 = 16.47%
106 ; CHECK: edge entry -> sw.bb1 probability is 0x60606060 / 0x80000000 = 75.29%
107
108 sw.bb:
109   br label %return
110
111 sw.bb1:
112   br label %return
113
114 return:
115   %retval.0 = phi i32 [ 5, %sw.bb1 ], [ 1, %sw.bb ], [ 0, %entry ]
116   ret i32 %retval.0
117 }
118
119 !2 = !{!"branch_weights", i32 7, i32 6, i32 4, i32 4, i32 64}
120
121 declare void @coldfunc() cold
122
123 define i32 @test5(i32 %a, i32 %b, i1 %flag) {
124 ; CHECK: Printing analysis {{.*}} for function 'test5'
125 entry:
126   br i1 %flag, label %then, label %else
127 ; CHECK: edge entry -> then probability is 0x07878788 / 0x80000000 = 5.88%
128 ; CHECK: edge entry -> else probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
129
130 then:
131   call void @coldfunc()
132   br label %exit
133 ; CHECK: edge then -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
134
135 else:
136   br label %exit
137 ; CHECK: edge else -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
138
139 exit:
140   %result = phi i32 [ %a, %then ], [ %b, %else ]
141   ret i32 %result
142 }
143
144 declare i32 @regular_function(i32 %i)
145
146 define i32 @test_cold_call_sites_with_prof(i32 %a, i32 %b, i1 %flag, i1 %flag2) {
147 ; CHECK: Printing analysis {{.*}} for function 'test_cold_call_sites_with_prof'
148 entry:
149   br i1 %flag, label %then, label %else
150 ; CHECK: edge entry -> then probability is 0x07878788 / 0x80000000 = 5.88%
151 ; CHECK: edge entry -> else probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
152
153 then:
154   br i1 %flag2, label %then2, label %else2, !prof !3
155 ; CHECK: edge then -> then2 probability is 0x7ebb907a / 0x80000000 = 99.01% [HOT edge]
156 ; CHECK: edge then -> else2 probability is 0x01446f86 / 0x80000000 = 0.99%
157
158 then2:
159   br label %join
160 ; CHECK: edge then2 -> join probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
161
162 else2:
163   br label %join
164 ; CHECK: edge else2 -> join probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
165
166 join:
167   %joinresult = phi i32 [ %a, %then2 ], [ %b, %else2 ]
168   call void @coldfunc()
169   br label %exit
170 ; CHECK: edge join -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
171
172 else:
173   br label %exit
174 ; CHECK: edge else -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
175
176 exit:
177   %result = phi i32 [ %joinresult, %join ], [ %b, %else ]
178   ret i32 %result
179 }
180
181 !3 = !{!"branch_weights", i32 100, i32 1}
182
183 define i32 @test_cold_call_sites(i32* %a) {
184 ; Test that edges to blocks post-dominated by cold call sites
185 ; are marked as not expected to be taken.
186 ; TODO(dnovillo) The calls to regular_function should not be merged, but
187 ; they are currently being merged. Convert this into a code generation test
188 ; after that is fixed.
189
190 ; CHECK: Printing analysis {{.*}} for function 'test_cold_call_sites'
191 ; CHECK: edge entry -> then probability is 0x07878788 / 0x80000000 = 5.88%
192 ; CHECK: edge entry -> else probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
193
194 entry:
195   %gep1 = getelementptr i32, i32* %a, i32 1
196   %val1 = load i32, i32* %gep1
197   %cond1 = icmp ugt i32 %val1, 1
198   br i1 %cond1, label %then, label %else
199
200 then:
201   ; This function is not declared cold, but this call site is.
202   %val4 = call i32 @regular_function(i32 %val1) cold
203   br label %exit
204
205 else:
206   %gep2 = getelementptr i32, i32* %a, i32 2
207   %val2 = load i32, i32* %gep2
208   %val3 = call i32 @regular_function(i32 %val2)
209   br label %exit
210
211 exit:
212   %ret = phi i32 [ %val4, %then ], [ %val3, %else ]
213   ret i32 %ret
214 }
215
216 ; CHECK-LABEL: test_invoke_code_callsite1
217 define i32 @test_invoke_code_callsite1(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
218 entry:
219   br i1 %c, label %if.then, label %if.end
220 ; Edge "entry->if.end" should have higher probability based on the cold call
221 ; heuristic which treat %if.then as a cold block because the normal destination
222 ; of the invoke instruction in %if.then is post-dominated by ColdFunc().
223 ; CHECK:  edge entry -> if.then probability is 0x07878788 / 0x80000000 = 5.88%
224 ; CHECK:  edge entry -> if.end probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
225
226 if.then:
227   invoke i32 @InvokeCall()
228           to label %invoke.cont unwind label %lpad
229 ; CHECK:  edge if.then -> invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
230 ; CHECK:  edge if.then -> lpad probability is 0x00000800 / 0x80000000 = 0.00%
231
232 invoke.cont:
233   call void @ColdFunc() #0
234   br label %if.end
235
236 lpad:
237   %ll = landingpad { i8*, i32 }
238           cleanup
239   br label %if.end
240
241 if.end:
242   ret i32 0
243 }
244
245 ; CHECK-LABEL: test_invoke_code_callsite2
246 define i32 @test_invoke_code_callsite2(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
247 entry:
248   br i1 %c, label %if.then, label %if.end
249
250 ; CHECK:  edge entry -> if.then probability is 0x40000000 / 0x80000000 = 50.00%
251 ; CHECK:  edge entry -> if.end probability is 0x40000000 / 0x80000000 = 50.00%
252
253 if.then:
254   invoke i32 @InvokeCall()
255           to label %invoke.cont unwind label %lpad
256 ; The cold call heuristic should not kick in when the cold callsite is in EH path.
257 ; CHECK:  edge if.then -> invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
258 ; CHECK:  edge if.then -> lpad probability is 0x00000800 / 0x80000000 = 0.00%
259
260 invoke.cont:
261   br label %if.end
262
263 lpad:
264   %ll = landingpad { i8*, i32 }
265           cleanup
266   call void @ColdFunc() #0
267   br label %if.end
268
269 if.end:
270   ret i32 0
271 }
272
273 ; CHECK-LABEL: test_invoke_code_callsite3
274 define i32 @test_invoke_code_callsite3(i1 %c) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
275 entry:
276   br i1 %c, label %if.then, label %if.end
277 ; CHECK: edge entry -> if.then probability is 0x07878788 / 0x80000000 = 5.88%
278 ; CHECK: edge entry -> if.end probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
279
280 if.then:
281   invoke i32 @InvokeCall()
282           to label %invoke.cont unwind label %lpad
283 ; Regardless of cold calls, edge weights from a invoke instruction should be
284 ; determined by the invoke heuristic.
285 ; CHECK: edge if.then -> invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
286 ; CHECK: edge if.then -> lpad probability is 0x00000800 / 0x80000000 = 0.00%
287
288 invoke.cont:
289   call void @ColdFunc() #0
290   br label %if.end
291
292 lpad:
293   %ll = landingpad { i8*, i32 }
294           cleanup
295   call void @ColdFunc() #0
296   br label %if.end
297
298 if.end:
299   ret i32 0
300 }
301
302 declare i32 @__gxx_personality_v0(...)
303 declare void  @ColdFunc()
304 declare i32 @InvokeCall()
305
306 attributes #0 = { cold }
307
308
309 define i32 @zero1(i32 %i, i32 %a, i32 %b) {
310 ; CHECK: Printing analysis {{.*}} for function 'zero1'
311 entry:
312   %cond = icmp eq i32 %i, 0
313   br i1 %cond, label %then, label %else
314 ; CHECK: edge entry -> then probability is 0x30000000 / 0x80000000 = 37.50%
315 ; CHECK: edge entry -> else probability is 0x50000000 / 0x80000000 = 62.50%
316
317 then:
318   br label %exit
319
320 else:
321   br label %exit
322
323 exit:
324   %result = phi i32 [ %a, %then ], [ %b, %else ]
325   ret i32 %result
326 }
327
328 define i32 @zero2(i32 %i, i32 %a, i32 %b) {
329 ; CHECK: Printing analysis {{.*}} for function 'zero2'
330 entry:
331   %cond = icmp ne i32 %i, -1
332   br i1 %cond, label %then, label %else
333 ; CHECK: edge entry -> then probability is 0x50000000 / 0x80000000 = 62.50%
334 ; CHECK: edge entry -> else probability is 0x30000000 / 0x80000000 = 37.50%
335
336 then:
337   br label %exit
338
339 else:
340   br label %exit
341
342 exit:
343   %result = phi i32 [ %a, %then ], [ %b, %else ]
344   ret i32 %result
345 }
346
347 define i32 @zero3(i32 %i, i32 %a, i32 %b) {
348 ; CHECK: Printing analysis {{.*}} for function 'zero3'
349 entry:
350 ; AND'ing with a single bit bitmask essentially leads to a bool comparison,
351 ; meaning we don't have probability information.
352   %and = and i32 %i, 2
353   %tobool = icmp eq i32 %and, 0
354   br i1 %tobool, label %then, label %else
355 ; CHECK: edge entry -> then probability is 0x40000000 / 0x80000000 = 50.00%
356 ; CHECK: edge entry -> else probability is 0x40000000 / 0x80000000 = 50.00%
357
358 then:
359 ; AND'ing with other bitmask might be something else, so we still assume the
360 ; usual probabilities.
361   %and2 = and i32 %i, 5
362   %tobool2 = icmp eq i32 %and2, 0
363   br i1 %tobool2, label %else, label %exit
364 ; CHECK: edge then -> else probability is 0x30000000 / 0x80000000 = 37.50%
365 ; CHECK: edge then -> exit probability is 0x50000000 / 0x80000000 = 62.50%
366
367 else:
368   br label %exit
369
370 exit:
371   %result = phi i32 [ %a, %then ], [ %b, %else ]
372   ret i32 %result
373 }
374
375 define i32 @test_unreachable_with_prof_greater(i32 %a, i32 %b) {
376 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_greater'
377 entry:
378   %cond = icmp eq i32 %a, 42
379   br i1 %cond, label %exit, label %unr, !prof !4
380
381 ; CHECK:  edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
382 ; CHECK:  edge entry -> unr probability is 0x00000001 / 0x80000000 = 0.00%
383
384 unr:
385   unreachable
386
387 exit:
388   ret i32 %b
389 }
390
391 !4 = !{!"branch_weights", i32 0, i32 1}
392
393 define i32 @test_unreachable_with_prof_equal(i32 %a, i32 %b) {
394 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_equal'
395 entry:
396   %cond = icmp eq i32 %a, 42
397   br i1 %cond, label %exit, label %unr, !prof !5
398
399 ; CHECK:  edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
400 ; CHECK:  edge entry -> unr probability is 0x00000001 / 0x80000000 = 0.00%
401
402 unr:
403   unreachable
404
405 exit:
406   ret i32 %b
407 }
408
409 !5 = !{!"branch_weights", i32 2147483647, i32 1}
410
411 define i32 @test_unreachable_with_prof_zero(i32 %a, i32 %b) {
412 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_zero'
413 entry:
414   %cond = icmp eq i32 %a, 42
415   br i1 %cond, label %exit, label %unr, !prof !6
416
417 ; CHECK:  edge entry -> exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
418 ; CHECK:  edge entry -> unr probability is 0x00000001 / 0x80000000 = 0.00%
419
420 unr:
421   unreachable
422
423 exit:
424   ret i32 %b
425 }
426
427 !6 = !{!"branch_weights", i32 0, i32 0}
428
429 define i32 @test_unreachable_with_prof_less(i32 %a, i32 %b) {
430 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_prof_less'
431 entry:
432   %cond = icmp eq i32 %a, 42
433   br i1 %cond, label %exit, label %unr, !prof !7
434
435 ; CHECK:  edge entry -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
436 ; CHECK:  edge entry -> unr probability is 0x00000000 / 0x80000000 = 0.00%
437
438 unr:
439   unreachable
440
441 exit:
442   ret i32 %b
443 }
444
445 !7 = !{!"branch_weights", i32 1, i32 0}
446
447 define i32 @test_unreachable_with_switch_prof1(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
448 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof1'
449 entry:
450   switch i32 %i, label %case_a [ i32 1, label %case_b
451                                  i32 2, label %case_c
452                                  i32 3, label %case_d
453                                  i32 4, label %case_e ], !prof !8
454 ; CHECK: edge entry -> case_a probability is 0x00000001 / 0x80000000 = 0.00%
455 ; CHECK: edge entry -> case_b probability is 0x07ffffff / 0x80000000 = 6.25%
456 ; CHECK: edge entry -> case_c probability is 0x67ffffff / 0x80000000 = 81.25% [HOT edge]
457 ; CHECK: edge entry -> case_d probability is 0x07ffffff / 0x80000000 = 6.25%
458 ; CHECK: edge entry -> case_e probability is 0x07ffffff / 0x80000000 = 6.25%
459
460 case_a:
461   unreachable
462
463 case_b:
464   br label %exit
465 ; CHECK: edge case_b -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
466
467 case_c:
468   br label %exit
469 ; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
470
471 case_d:
472   br label %exit
473 ; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
474
475 case_e:
476   br label %exit
477 ; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
478
479 exit:
480   %result = phi i32 [ %b, %case_b ],
481                     [ %c, %case_c ],
482                     [ %d, %case_d ],
483                     [ %e, %case_e ]
484   ret i32 %result
485 }
486
487 !8 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
488
489 define i32 @test_unreachable_with_switch_prof2(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
490 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof2'
491 entry:
492   switch i32 %i, label %case_a [ i32 1, label %case_b
493                                  i32 2, label %case_c
494                                  i32 3, label %case_d
495                                  i32 4, label %case_e ], !prof !9
496 ; CHECK: edge entry -> case_a probability is 0x00000001 / 0x80000000 = 0.00%
497 ; CHECK: edge entry -> case_b probability is 0x00000001 / 0x80000000 = 0.00%
498 ; CHECK: edge entry -> case_c probability is 0x6aaaaaa9 / 0x80000000 = 83.33% [HOT edge]
499 ; CHECK: edge entry -> case_d probability is 0x0aaaaaa9 / 0x80000000 = 8.33%
500 ; CHECK: edge entry -> case_e probability is 0x0aaaaaa9 / 0x80000000 = 8.33%
501
502 case_a:
503   unreachable
504
505 case_b:
506   unreachable
507
508 case_c:
509   br label %exit
510 ; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
511
512 case_d:
513   br label %exit
514 ; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
515
516 case_e:
517   br label %exit
518 ; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
519
520 exit:
521   %result = phi i32 [ %c, %case_c ],
522                     [ %d, %case_d ],
523                     [ %e, %case_e ]
524   ret i32 %result
525 }
526
527 !9 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
528
529 define i32 @test_unreachable_with_switch_prof3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
530 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof3'
531 entry:
532   switch i32 %i, label %case_a [ i32 1, label %case_b
533                                  i32 2, label %case_c
534                                  i32 3, label %case_d
535                                  i32 4, label %case_e ], !prof !10
536 ; CHECK: edge entry -> case_a probability is 0x00000000 / 0x80000000 = 0.00%
537 ; CHECK: edge entry -> case_b probability is 0x00000001 / 0x80000000 = 0.00%
538 ; CHECK: edge entry -> case_c probability is 0x6e08fb82 / 0x80000000 = 85.96% [HOT edge]
539 ; CHECK: edge entry -> case_d probability is 0x08fb823e / 0x80000000 = 7.02%
540 ; CHECK: edge entry -> case_e probability is 0x08fb823e / 0x80000000 = 7.02%
541
542 case_a:
543   unreachable
544
545 case_b:
546   unreachable
547
548 case_c:
549   br label %exit
550 ; CHECK: edge case_c -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
551
552 case_d:
553   br label %exit
554 ; CHECK: edge case_d -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
555
556 case_e:
557   br label %exit
558 ; CHECK: edge case_e -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
559
560 exit:
561   %result = phi i32 [ %c, %case_c ],
562                     [ %d, %case_d ],
563                     [ %e, %case_e ]
564   ret i32 %result
565 }
566
567 !10 = !{!"branch_weights", i32 0, i32 4, i32 64, i32 4, i32 4}
568
569 define i32 @test_unreachable_with_switch_prof4(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
570 ; CHECK: Printing analysis {{.*}} for function 'test_unreachable_with_switch_prof4'
571 entry:
572   switch i32 %i, label %case_a [ i32 1, label %case_b
573                                  i32 2, label %case_c
574                                  i32 3, label %case_d
575                                  i32 4, label %case_e ], !prof !11
576 ; CHECK: edge entry -> case_a probability is 0x1999999a / 0x80000000 = 20.00%
577 ; CHECK: edge entry -> case_b probability is 0x1999999a / 0x80000000 = 20.00%
578 ; CHECK: edge entry -> case_c probability is 0x1999999a / 0x80000000 = 20.00%
579 ; CHECK: edge entry -> case_d probability is 0x1999999a / 0x80000000 = 20.00%
580 ; CHECK: edge entry -> case_e probability is 0x1999999a / 0x80000000 = 20.00%
581
582 case_a:
583   unreachable
584
585 case_b:
586   unreachable
587
588 case_c:
589   unreachable
590
591 case_d:
592   unreachable
593
594 case_e:
595   unreachable
596
597 }
598
599 !11 = !{!"branch_weights", i32 0, i32 4, i32 64, i32 4, i32 4}