1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
4 define i32 @test1(i32 %i, ptr %a) {
6 ; CHECK-NEXT: ---- Branch Probabilities ----
7 ; CHECK-NEXT: edge %entry -> %body probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
8 ; CHECK-NEXT: edge %body -> %exit probability is 0x04000000 / 0x80000000 = 3.12%
9 ; CHECK-NEXT: edge %body -> %body probability is 0x7c000000 / 0x80000000 = 96.88% [HOT edge]
15 %iv = phi i32 [ 0, %entry ], [ %next, %body ]
16 %base = phi i32 [ 0, %entry ], [ %sum, %body ]
17 %arrayidx = getelementptr inbounds i32, ptr %a, i32 %iv
18 %0 = load i32, ptr %arrayidx
19 %sum = add nsw i32 %0, %base
20 %next = add i32 %iv, 1
21 %exitcond = icmp eq i32 %next, %i
22 br i1 %exitcond, label %exit, label %body
28 define i32 @test2(i32 %i, i32 %a, i32 %b) {
29 ; CHECK-LABEL: 'test2'
30 ; CHECK-NEXT: ---- Branch Probabilities ----
31 ; CHECK-NEXT: edge %entry -> %then probability is 0x78787878 / 0x80000000 = 94.12% [HOT edge]
32 ; CHECK-NEXT: edge %entry -> %else probability is 0x07878788 / 0x80000000 = 5.88%
33 ; CHECK-NEXT: edge %then -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
34 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
37 %cond = icmp ult i32 %i, 42
38 br i1 %cond, label %then, label %else, !prof !0
47 %result = phi i32 [ %a, %then ], [ %b, %else ]
51 !0 = !{!"branch_weights", i32 64, i32 4}
53 define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
54 ; CHECK-LABEL: 'test3'
55 ; CHECK-NEXT: ---- Branch Probabilities ----
56 ; CHECK-NEXT: edge %entry -> %case_a probability is 0x06666666 / 0x80000000 = 5.00%
57 ; CHECK-NEXT: edge %entry -> %case_b probability is 0x06666666 / 0x80000000 = 5.00%
58 ; CHECK-NEXT: edge %entry -> %case_c probability is 0x66666666 / 0x80000000 = 80.00%
59 ; CHECK-NEXT: edge %entry -> %case_d probability is 0x06666666 / 0x80000000 = 5.00%
60 ; CHECK-NEXT: edge %entry -> %case_e probability is 0x06666666 / 0x80000000 = 5.00%
61 ; CHECK-NEXT: edge %case_a -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
62 ; CHECK-NEXT: edge %case_b -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
63 ; CHECK-NEXT: edge %case_c -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
64 ; CHECK-NEXT: edge %case_d -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
65 ; CHECK-NEXT: edge %case_e -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
68 switch i32 %i, label %case_a [ i32 1, label %case_b
71 i32 4, label %case_e ], !prof !1
89 %result = phi i32 [ %a, %case_a ], [ %b, %case_b ], [ %c, %case_c ], [ %d, %case_d ], [ %e, %case_e ]
93 !1 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
95 define i32 @test4(i32 %x) nounwind uwtable readnone ssp {
96 ; CHECK-LABEL: 'test4'
97 ; CHECK-NEXT: ---- Branch Probabilities ----
98 ; CHECK-NEXT: edge %entry -> %return probability is 0x0a8a8a8b / 0x80000000 = 8.24%
99 ; CHECK-NEXT: edge %entry -> %sw.bb probability is 0x15151515 / 0x80000000 = 16.47%
100 ; CHECK-NEXT: edge %entry -> %sw.bb probability is 0x15151515 / 0x80000000 = 16.47%
101 ; CHECK-NEXT: edge %entry -> %sw.bb probability is 0x15151515 / 0x80000000 = 16.47%
102 ; CHECK-NEXT: edge %entry -> %sw.bb1 probability is 0x60606060 / 0x80000000 = 75.29%
103 ; CHECK-NEXT: edge %sw.bb -> %return probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
104 ; CHECK-NEXT: edge %sw.bb1 -> %return probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
107 %conv = sext i32 %x to i64
108 switch i64 %conv, label %return [
122 %retval.0 = phi i32 [ 5, %sw.bb1 ], [ 1, %sw.bb ], [ 0, %entry ]
126 !2 = !{!"branch_weights", i32 7, i32 6, i32 4, i32 4, i32 64}
128 declare void @coldfunc() cold
130 define i32 @test5(i32 %a, i32 %b, i1 %flag) {
131 ; CHECK-LABEL: 'test5'
132 ; CHECK-NEXT: ---- Branch Probabilities ----
133 ; CHECK-NEXT: edge %entry -> %then probability is 0x078780e3 / 0x80000000 = 5.88%
134 ; CHECK-NEXT: edge %entry -> %else probability is 0x78787f1d / 0x80000000 = 94.12% [HOT edge]
135 ; CHECK-NEXT: edge %then -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
136 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
139 br i1 %flag, label %then, label %else
142 call void @coldfunc()
149 %result = phi i32 [ %a, %then ], [ %b, %else ]
153 define i32 @test_cold_loop(i32 %a, i32 %b) {
154 ; CHECK-LABEL: 'test_cold_loop'
155 ; CHECK-NEXT: ---- Branch Probabilities ----
156 ; CHECK-NEXT: edge %entry -> %header probability is 0x40000000 / 0x80000000 = 50.00%
157 ; CHECK-NEXT: edge %entry -> %exit probability is 0x40000000 / 0x80000000 = 50.00%
158 ; CHECK-NEXT: edge %header -> %body probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
159 ; CHECK-NEXT: edge %body -> %header probability is 0x7fbe1203 / 0x80000000 = 99.80% [HOT edge]
160 ; CHECK-NEXT: edge %body -> %exit probability is 0x0041edfd / 0x80000000 = 0.20%
163 %cond1 = icmp eq i32 %a, 42
164 br i1 %cond1, label %header, label %exit
169 %cond2 = icmp eq i32 %b, 42
170 br i1 %cond2, label %header, label %exit
172 call void @coldfunc()
176 declare i32 @regular_function(i32 %i)
178 define i32 @test_cold_call_sites_with_prof(i32 %a, i32 %b, i1 %flag, i1 %flag2) {
179 ; CHECK-LABEL: 'test_cold_call_sites_with_prof'
180 ; CHECK-NEXT: ---- Branch Probabilities ----
181 ; CHECK-NEXT: edge %entry -> %then probability is 0x078780e3 / 0x80000000 = 5.88%
182 ; CHECK-NEXT: edge %entry -> %else probability is 0x78787f1d / 0x80000000 = 94.12% [HOT edge]
183 ; CHECK-NEXT: edge %then -> %then2 probability is 0x7ebb907a / 0x80000000 = 99.01% [HOT edge]
184 ; CHECK-NEXT: edge %then -> %else2 probability is 0x01446f86 / 0x80000000 = 0.99%
185 ; CHECK-NEXT: edge %then2 -> %join probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
186 ; CHECK-NEXT: edge %else2 -> %join probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
187 ; CHECK-NEXT: edge %join -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
188 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
191 br i1 %flag, label %then, label %else
194 br i1 %flag2, label %then2, label %else2, !prof !3
203 %joinresult = phi i32 [ %a, %then2 ], [ %b, %else2 ]
204 call void @coldfunc()
211 %result = phi i32 [ %joinresult, %join ], [ %b, %else ]
215 !3 = !{!"branch_weights", i32 100, i32 1}
217 define i32 @test_cold_call_sites(ptr %a) {
218 ; Test that edges to blocks post-dominated by cold call sites
219 ; are marked as not expected to be taken.
220 ; TODO(dnovillo) The calls to regular_function should not be merged, but
221 ; they are currently being merged. Convert this into a code generation test
222 ; after that is fixed.
223 ; CHECK-LABEL: 'test_cold_call_sites'
224 ; CHECK-NEXT: ---- Branch Probabilities ----
225 ; CHECK-NEXT: edge %entry -> %then probability is 0x078780e3 / 0x80000000 = 5.88%
226 ; CHECK-NEXT: edge %entry -> %else probability is 0x78787f1d / 0x80000000 = 94.12% [HOT edge]
227 ; CHECK-NEXT: edge %then -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
228 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
232 %gep1 = getelementptr i32, ptr %a, i32 1
233 %val1 = load i32, ptr %gep1
234 %cond1 = icmp ugt i32 %val1, 1
235 br i1 %cond1, label %then, label %else
238 ; This function is not declared cold, but this call site is.
239 %val4 = call i32 @regular_function(i32 %val1) cold
243 %gep2 = getelementptr i32, ptr %a, i32 2
244 %val2 = load i32, ptr %gep2
245 %val3 = call i32 @regular_function(i32 %val2)
249 %ret = phi i32 [ %val4, %then ], [ %val3, %else ]
253 define i32 @test_invoke_code_callsite1(i1 %c) personality ptr @__gxx_personality_v0 {
254 ; CHECK-LABEL: 'test_invoke_code_callsite1'
255 ; CHECK-NEXT: ---- Branch Probabilities ----
256 ; CHECK-NEXT: edge %entry -> %if.then probability is 0x078780e3 / 0x80000000 = 5.88%
257 ; CHECK-NEXT: edge %entry -> %if.end probability is 0x78787f1d / 0x80000000 = 94.12% [HOT edge]
258 ; CHECK-NEXT: edge %if.then -> %invoke.cont probability is 0x7fff8000 / 0x80000000 = 100.00% [HOT edge]
259 ; CHECK-NEXT: edge %if.then -> %lpad probability is 0x00008000 / 0x80000000 = 0.00%
260 ; CHECK-NEXT: edge %invoke.cont -> %if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
261 ; CHECK-NEXT: edge %lpad -> %if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
264 br i1 %c, label %if.then, label %if.end
265 ; Edge "entry->if.end" should have higher probability based on the cold call
266 ; heuristic which treat %if.then as a cold block because the normal destination
267 ; of the invoke instruction in %if.then is post-dominated by ColdFunc().
270 invoke i32 @InvokeCall()
271 to label %invoke.cont unwind label %lpad
274 call void @ColdFunc() #0
278 %ll = landingpad { ptr, i32 }
286 define i32 @test_invoke_code_callsite2(i1 %c) personality ptr @__gxx_personality_v0 {
287 ; CHECK-LABEL: 'test_invoke_code_callsite2'
288 ; CHECK-NEXT: ---- Branch Probabilities ----
289 ; CHECK-NEXT: edge %entry -> %if.then probability is 0x40000000 / 0x80000000 = 50.00%
290 ; CHECK-NEXT: edge %entry -> %if.end probability is 0x40000000 / 0x80000000 = 50.00%
291 ; CHECK-NEXT: edge %if.then -> %invoke.cont probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
292 ; CHECK-NEXT: edge %if.then -> %lpad probability is 0x00000800 / 0x80000000 = 0.00%
293 ; CHECK-NEXT: edge %invoke.cont -> %if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
294 ; CHECK-NEXT: edge %lpad -> %if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
297 br i1 %c, label %if.then, label %if.end
300 invoke i32 @InvokeCall()
301 to label %invoke.cont unwind label %lpad
302 ; The cold call heuristic should not kick in when the cold callsite is in EH path.
308 %ll = landingpad { ptr, i32 }
310 call void @ColdFunc() #0
317 define i32 @test_invoke_code_callsite3(i1 %c) personality ptr @__gxx_personality_v0 {
318 ; CHECK-LABEL: 'test_invoke_code_callsite3'
319 ; CHECK-NEXT: ---- Branch Probabilities ----
320 ; CHECK-NEXT: edge %entry -> %if.then probability is 0x078780e3 / 0x80000000 = 5.88%
321 ; CHECK-NEXT: edge %entry -> %if.end probability is 0x78787f1d / 0x80000000 = 94.12% [HOT edge]
322 ; CHECK-NEXT: edge %if.then -> %invoke.cont probability is 0x7fff8000 / 0x80000000 = 100.00% [HOT edge]
323 ; CHECK-NEXT: edge %if.then -> %lpad probability is 0x00008000 / 0x80000000 = 0.00%
324 ; CHECK-NEXT: edge %invoke.cont -> %if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
325 ; CHECK-NEXT: edge %lpad -> %if.end probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
328 br i1 %c, label %if.then, label %if.end
331 invoke i32 @InvokeCall()
332 to label %invoke.cont unwind label %lpad
333 ; Regardless of cold calls, edge weights from a invoke instruction should be
334 ; determined by the invoke heuristic.
337 call void @ColdFunc() #0
341 %ll = landingpad { ptr, i32 }
343 call void @ColdFunc() #0
350 define void @test_invoke_code_profiled(i1 %c) personality ptr @__gxx_personality_v0 {
351 ; CHECK-LABEL: 'test_invoke_code_profiled'
352 ; CHECK-NEXT: ---- Branch Probabilities ----
353 ; CHECK-NEXT: edge %entry -> %invoke.to0 probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
354 ; CHECK-NEXT: edge %entry -> %lpad probability is 0x00000800 / 0x80000000 = 0.00%
355 ; CHECK-NEXT: edge %invoke.to0 -> %invoke.to1 probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
356 ; CHECK-NEXT: edge %invoke.to0 -> %lpad probability is 0x00000800 / 0x80000000 = 0.00%
357 ; CHECK-NEXT: edge %invoke.to1 -> %invoke.to2 probability is 0x55555555 / 0x80000000 = 66.67%
358 ; CHECK-NEXT: edge %invoke.to1 -> %lpad probability is 0x2aaaaaab / 0x80000000 = 33.33%
361 invoke i32 @InvokeCall() to label %invoke.to0 unwind label %lpad
364 invoke i32 @InvokeCall() to label %invoke.to1 unwind label %lpad,
365 !prof !{!"branch_weights", i32 444}
368 invoke i32 @InvokeCall() to label %invoke.to2 unwind label %lpad,
369 !prof !{!"branch_weights", i32 222, i32 111}
376 %ll = landingpad { ptr, i32 }
381 declare i32 @__gxx_personality_v0(...)
382 declare void @ColdFunc()
383 declare i32 @InvokeCall()
385 attributes #0 = { cold }
388 define i32 @zero1(i32 %i, i32 %a, i32 %b) {
389 ; CHECK-LABEL: 'zero1'
390 ; CHECK-NEXT: ---- Branch Probabilities ----
391 ; CHECK-NEXT: edge %entry -> %then probability is 0x30000000 / 0x80000000 = 37.50%
392 ; CHECK-NEXT: edge %entry -> %else probability is 0x50000000 / 0x80000000 = 62.50%
393 ; CHECK-NEXT: edge %then -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
394 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
397 %cond = icmp eq i32 %i, 0
398 br i1 %cond, label %then, label %else
407 %result = phi i32 [ %a, %then ], [ %b, %else ]
411 define i32 @zero2(i32 %i, i32 %a, i32 %b) {
412 ; CHECK-LABEL: 'zero2'
413 ; CHECK-NEXT: ---- Branch Probabilities ----
414 ; CHECK-NEXT: edge %entry -> %then probability is 0x50000000 / 0x80000000 = 62.50%
415 ; CHECK-NEXT: edge %entry -> %else probability is 0x30000000 / 0x80000000 = 37.50%
416 ; CHECK-NEXT: edge %then -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
417 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
420 %cond = icmp ne i32 %i, -1
421 br i1 %cond, label %then, label %else
430 %result = phi i32 [ %a, %then ], [ %b, %else ]
434 define i32 @zero3(i32 %i, i32 %a, i32 %b) {
435 ; CHECK-LABEL: 'zero3'
436 ; CHECK-NEXT: ---- Branch Probabilities ----
437 ; CHECK-NEXT: edge %entry -> %then probability is 0x40000000 / 0x80000000 = 50.00%
438 ; CHECK-NEXT: edge %entry -> %else probability is 0x40000000 / 0x80000000 = 50.00%
439 ; CHECK-NEXT: edge %then -> %else probability is 0x30000000 / 0x80000000 = 37.50%
440 ; CHECK-NEXT: edge %then -> %exit probability is 0x50000000 / 0x80000000 = 62.50%
441 ; CHECK-NEXT: edge %else -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
444 ; AND'ing with a single bit bitmask essentially leads to a bool comparison,
445 ; meaning we don't have probability information.
447 %tobool = icmp eq i32 %and, 0
448 br i1 %tobool, label %then, label %else
451 ; AND'ing with other bitmask might be something else, so we still assume the
452 ; usual probabilities.
453 %and2 = and i32 %i, 5
454 %tobool2 = icmp eq i32 %and2, 0
455 br i1 %tobool2, label %else, label %exit
461 %result = phi i32 [ %a, %then ], [ %b, %else ]
465 define i32 @test_unreachable_with_prof_greater(i32 %a, i32 %b) {
466 ; CHECK-LABEL: 'test_unreachable_with_prof_greater'
467 ; CHECK-NEXT: ---- Branch Probabilities ----
468 ; CHECK-NEXT: edge %entry -> %exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
469 ; CHECK-NEXT: edge %entry -> %unr probability is 0x00000001 / 0x80000000 = 0.00%
472 %cond = icmp eq i32 %a, 42
473 br i1 %cond, label %exit, label %unr, !prof !4
483 !4 = !{!"branch_weights", i32 0, i32 1}
485 define i32 @test_unreachable_with_prof_equal(i32 %a, i32 %b) {
486 ; CHECK-LABEL: 'test_unreachable_with_prof_equal'
487 ; CHECK-NEXT: ---- Branch Probabilities ----
488 ; CHECK-NEXT: edge %entry -> %exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
489 ; CHECK-NEXT: edge %entry -> %unr probability is 0x00000001 / 0x80000000 = 0.00%
492 %cond = icmp eq i32 %a, 42
493 br i1 %cond, label %exit, label %unr, !prof !5
503 !5 = !{!"branch_weights", i32 2147483647, i32 1}
505 define i32 @test_unreachable_with_prof_zero(i32 %a, i32 %b) {
506 ; CHECK-LABEL: 'test_unreachable_with_prof_zero'
507 ; CHECK-NEXT: ---- Branch Probabilities ----
508 ; CHECK-NEXT: edge %entry -> %exit probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
509 ; CHECK-NEXT: edge %entry -> %unr probability is 0x00000001 / 0x80000000 = 0.00%
512 %cond = icmp eq i32 %a, 42
513 br i1 %cond, label %exit, label %unr, !prof !6
523 !6 = !{!"branch_weights", i32 0, i32 0}
525 define i32 @test_unreachable_with_prof_less(i32 %a, i32 %b) {
526 ; CHECK-LABEL: 'test_unreachable_with_prof_less'
527 ; CHECK-NEXT: ---- Branch Probabilities ----
528 ; CHECK-NEXT: edge %entry -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
529 ; CHECK-NEXT: edge %entry -> %unr probability is 0x00000000 / 0x80000000 = 0.00%
532 %cond = icmp eq i32 %a, 42
533 br i1 %cond, label %exit, label %unr, !prof !7
543 !7 = !{!"branch_weights", i32 1, i32 0}
545 define i32 @test_unreachable_with_switch_prof1(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
546 ; CHECK-LABEL: 'test_unreachable_with_switch_prof1'
547 ; CHECK-NEXT: ---- Branch Probabilities ----
548 ; CHECK-NEXT: edge %entry -> %case_a probability is 0x00000001 / 0x80000000 = 0.00%
549 ; CHECK-NEXT: edge %entry -> %case_b probability is 0x06bca1af / 0x80000000 = 5.26%
550 ; CHECK-NEXT: edge %entry -> %case_c probability is 0x6bca1af3 / 0x80000000 = 84.21% [HOT edge]
551 ; CHECK-NEXT: edge %entry -> %case_d probability is 0x06bca1af / 0x80000000 = 5.26%
552 ; CHECK-NEXT: edge %entry -> %case_e probability is 0x06bca1af / 0x80000000 = 5.26%
553 ; CHECK-NEXT: edge %case_b -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
554 ; CHECK-NEXT: edge %case_c -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
555 ; CHECK-NEXT: edge %case_d -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
556 ; CHECK-NEXT: edge %case_e -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
559 switch i32 %i, label %case_a [
563 i32 4, label %case_e ], !prof !8
564 ; Reachable probabilities keep their relation: 4/64/4/4 = 5.26% / 84.21% / 5.26% / 5.26%.
582 %result = phi i32 [ %b, %case_b ],
589 !8 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
591 define i32 @test_unreachable_with_switch_prof2(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
592 ; CHECK-LABEL: 'test_unreachable_with_switch_prof2'
593 ; CHECK-NEXT: ---- Branch Probabilities ----
594 ; CHECK-NEXT: edge %entry -> %case_a probability is 0x00000001 / 0x80000000 = 0.00%
595 ; CHECK-NEXT: edge %entry -> %case_b probability is 0x00000001 / 0x80000000 = 0.00%
596 ; CHECK-NEXT: edge %entry -> %case_c probability is 0x71c71c71 / 0x80000000 = 88.89% [HOT edge]
597 ; CHECK-NEXT: edge %entry -> %case_d probability is 0x071c71c7 / 0x80000000 = 5.56%
598 ; CHECK-NEXT: edge %entry -> %case_e probability is 0x071c71c7 / 0x80000000 = 5.56%
599 ; CHECK-NEXT: edge %case_c -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
600 ; CHECK-NEXT: edge %case_d -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
601 ; CHECK-NEXT: edge %case_e -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
604 switch i32 %i, label %case_a [ i32 1, label %case_b
607 i32 4, label %case_e ], !prof !9
608 ; Reachable probabilities keep their relation: 64/4/4 = 88.89% / 5.56% / 5.56%.
627 %result = phi i32 [ %c, %case_c ],
633 !9 = !{!"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
635 define i32 @test_unreachable_with_switch_prof3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
636 ; CHECK-LABEL: 'test_unreachable_with_switch_prof3'
637 ; CHECK-NEXT: ---- Branch Probabilities ----
638 ; CHECK-NEXT: edge %entry -> %case_a probability is 0x00000000 / 0x80000000 = 0.00%
639 ; CHECK-NEXT: edge %entry -> %case_b probability is 0x00000001 / 0x80000000 = 0.00%
640 ; CHECK-NEXT: edge %entry -> %case_c probability is 0x71c71c71 / 0x80000000 = 88.89% [HOT edge]
641 ; CHECK-NEXT: edge %entry -> %case_d probability is 0x071c71c7 / 0x80000000 = 5.56%
642 ; CHECK-NEXT: edge %entry -> %case_e probability is 0x071c71c7 / 0x80000000 = 5.56%
643 ; CHECK-NEXT: edge %case_c -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
644 ; CHECK-NEXT: edge %case_d -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
645 ; CHECK-NEXT: edge %case_e -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
648 switch i32 %i, label %case_a [ i32 1, label %case_b
651 i32 4, label %case_e ], !prof !10
652 ; Reachable probabilities keep their relation: 64/4/4 = 88.89% / 5.56% / 5.56%.
670 %result = phi i32 [ %c, %case_c ],
676 !10 = !{!"branch_weights", i32 0, i32 4, i32 64, i32 4, i32 4}
678 define i32 @test_unreachable_with_switch_prof4(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
679 ; CHECK-LABEL: 'test_unreachable_with_switch_prof4'
680 ; CHECK-NEXT: ---- Branch Probabilities ----
681 ; CHECK-NEXT: edge %entry -> %case_a probability is 0x1999999a / 0x80000000 = 20.00%
682 ; CHECK-NEXT: edge %entry -> %case_b probability is 0x1999999a / 0x80000000 = 20.00%
683 ; CHECK-NEXT: edge %entry -> %case_c probability is 0x1999999a / 0x80000000 = 20.00%
684 ; CHECK-NEXT: edge %entry -> %case_d probability is 0x1999999a / 0x80000000 = 20.00%
685 ; CHECK-NEXT: edge %entry -> %case_e probability is 0x1999999a / 0x80000000 = 20.00%
688 switch i32 %i, label %case_a [ i32 1, label %case_b
691 i32 4, label %case_e ], !prof !11
710 !11 = !{!"branch_weights", i32 0, i32 4, i32 64, i32 4, i32 4}