1 ; RUN: opt < %s -passes="print<branch-prob>,instcombine,print<branch-prob>" -S 2>&1 | FileCheck %s
3 ; CHECK: Printing analysis 'Branch Probability Analysis' for function 'invert_cond':
4 ; CHECK-NEXT: ---- Branch Probabilities ----
5 ; CHECK-NEXT: edge %entry -> %bb1 probability is 0x06186186 / 0x80000000 = 4.76%
6 ; CHECK-NEXT: edge %entry -> %bb2 probability is 0x79e79e7a / 0x80000000 = 95.24% [HOT edge]
7 ; CHECK-NEXT: Printing analysis 'Branch Probability Analysis' for function 'invert_cond':
8 ; CHECK-NEXT: ---- Branch Probabilities ----
9 ; CHECK-NEXT: edge %entry -> %bb2 probability is 0x79e79e7a / 0x80000000 = 95.24% [HOT edge]
10 ; CHECK-NEXT: edge %entry -> %bb1 probability is 0x06186186 / 0x80000000 = 4.76%
12 define i32 @invert_cond(ptr %p) {
13 ; CHECK-LABEL: define i32 @invert_cond(
14 ; CHECK-SAME: ptr [[P:%.*]]) {
16 ; CHECK-NEXT: [[COND_NOT:%.*]] = icmp eq ptr [[P]], null
17 ; CHECK-NEXT: br i1 [[COND_NOT]], label [[BB2:%.*]], label [[BB1:%.*]], !prof [[PROF0:![0-9]+]]
19 ; CHECK-NEXT: ret i32 0
21 ; CHECK-NEXT: ret i32 1
24 %cond = icmp ne ptr %p, null
25 br i1 %cond, label %bb1, label %bb2, !prof !1
34 !1 = !{!"branch_weights", i32 1, i32 20}
35 ; CHECK: [[PROF0]] = !{!"branch_weights", i32 20, i32 1}