xref: /llvm-project/llvm/test/Transforms/InstCombine/update-bpi.ll (revision d8503a38b974930599417a747cec3615330c367e)
1; RUN: opt < %s -passes="print<branch-prob>,instcombine,print<branch-prob>" -S 2>&1 | FileCheck %s
2
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%
11
12define i32 @invert_cond(ptr %p) {
13; CHECK-LABEL: define i32 @invert_cond(
14; CHECK-SAME: ptr [[P:%.*]]) {
15; CHECK-NEXT:  entry:
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]+]]
18; CHECK:       bb1:
19; CHECK-NEXT:    ret i32 0
20; CHECK:       bb2:
21; CHECK-NEXT:    ret i32 1
22;
23entry:
24  %cond = icmp ne ptr %p, null
25  br i1 %cond, label %bb1, label %bb2, !prof !1
26
27bb1:
28  ret i32 0;
29
30bb2:
31  ret i32 1;
32}
33
34!1 = !{!"branch_weights", i32 1, i32 20}
35; CHECK: [[PROF0]] = !{!"branch_weights", i32 20, i32 1}
36
37