xref: /llvm-project/llvm/test/Analysis/BranchProbabilityInfo/hoist.ll (revision bb6497ffa6a88d1b3a32101d9b6519094d75ef2a)
1; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
2
3; CHECK-LABEL: no_hoist
4; CHECK: edge %entry -> %if.end probability is 0x40000000 / 0x80000000 = 50.00%
5; CHECK: edge %entry -> %if.then probability is 0x40000000 / 0x80000000 = 50.00%
6; CHECK: edge %if.end -> %if.end4 probability is 0x40000000 / 0x80000000 = 50.00%
7; CHECK: edge %if.end -> %if.then3 probability is 0x40000000 / 0x80000000 = 50.00%
8define dso_local void @no_hoist(i64 %arg1, i64 %arg2) local_unnamed_addr #0 {
9entry:
10  %and = and i64 %arg1, 1152921504606846976
11  %tobool.not = icmp eq i64 %and, 0
12  br i1 %tobool.not, label %if.end, label %if.then
13
14if.then:                                          ; preds = %entry
15  tail call void @bar()
16  br label %if.end
17
18if.end:                                           ; preds = %if.then, %entry
19  %and1 = and i64 %arg2, 1152921504606846976
20  %tobool2.not = icmp eq i64 %and1, 0
21  br i1 %tobool2.not, label %if.end4, label %if.then3
22
23if.then3:                                         ; preds = %if.end
24  tail call void @baz()
25  br label %if.end4
26
27if.end4:                                          ; preds = %if.then3, %if.end
28  ret void
29}
30
31; CHECK-LABEL: hoist
32; CHECK: edge %entry -> %if.end probability is 0x40000000 / 0x80000000 = 50.00%
33; CHECK: edge %entry -> %if.then probability is 0x40000000 / 0x80000000 = 50.00%
34; CHECK: edge %if.end -> %if.end4 probability is 0x40000000 / 0x80000000 = 50.00%
35; CHECK: edge %if.end -> %if.then3 probability is 0x40000000 / 0x80000000 = 50.00%
36define dso_local void @hoist(i64 %arg1, i64 %arg2) local_unnamed_addr #0 {
37entry:
38  %const = bitcast i64 1152921504606846976 to i64
39  %and = and i64 %arg1, %const
40  %tobool.not = icmp eq i64 %and, 0
41  br i1 %tobool.not, label %if.end, label %if.then
42
43if.then:                                          ; preds = %entry
44  tail call void @bar()
45  br label %if.end
46
47if.end:                                           ; preds = %if.then, %entry
48  %and1 = and i64 %arg2, %const
49  %tobool2.not = icmp eq i64 %and1, 0
50  br i1 %tobool2.not, label %if.end4, label %if.then3
51
52if.then3:                                         ; preds = %if.end
53  tail call void @baz()
54  br label %if.end4
55
56if.end4:                                          ; preds = %if.then3, %if.end
57  ret void
58}
59
60declare dso_local void @bar() local_unnamed_addr #1
61
62declare dso_local void @baz() local_unnamed_addr #1
63