1 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
3 define i32 @cmp1(ptr readnone %0, ptr readnone %1) {
5 %3 = icmp eq ptr %0, %1
6 br i1 %3, label %4, label %6
7 ; CHECK: edge %2 -> %4 probability is 0x30000000 / 0x80000000 = 37.50%
8 ; CHECK: edge %2 -> %6 probability is 0x50000000 / 0x80000000 = 62.50%
11 %5 = tail call i32 @f() #2
13 ; CHECK: edge %4 -> %8 probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
16 %7 = tail call i32 @g() #2
18 ; CHECK: edge %6 -> %8 probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
21 %9 = phi i32 [ %5, %4 ], [ %7, %6 ]
25 define i32 @cmp2(ptr readnone %0, ptr readnone %1) {
27 %3 = icmp eq ptr %0, %1
28 br i1 %3, label %6, label %4
29 ; CHECK: edge %2 -> %6 probability is 0x30000000 / 0x80000000 = 37.50%
30 ; CHECK: edge %2 -> %4 probability is 0x50000000 / 0x80000000 = 62.50%
33 %5 = tail call i32 @f() #2
35 ; CHECK: edge %4 -> %8 probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
38 %7 = tail call i32 @g() #2
40 ; CHECK: edge %6 -> %8 probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
43 %9 = phi i32 [ %5, %4 ], [ %7, %6 ]
47 define i32 @cmp3(ptr readnone %0) {
49 %2 = icmp eq ptr %0, null
50 br i1 %2, label %3, label %5
51 ; CHECK: edge %1 -> %3 probability is 0x30000000 / 0x80000000 = 37.50%
52 ; CHECK: edge %1 -> %5 probability is 0x50000000 / 0x80000000 = 62.50%
55 %4 = tail call i32 @f() #2
57 ; CHECK: edge %3 -> %7 probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
60 %6 = tail call i32 @g() #2
62 ; CHECK: edge %5 -> %7 probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
65 %8 = phi i32 [ %6, %5 ], [ %4, %3 ]
69 declare dso_local i32 @f(...) local_unnamed_addr #1
70 declare dso_local i32 @g(...) local_unnamed_addr #1