1; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
2
3; Cold function, %dup should not be duplicated into predecessors.
4define i32 @cold(i32 %a, i32* %p, i32* %q) !prof !21 {
5; CHECK-LABEL: cold
6; CHECK:       %entry
7; CHECK:       %true1
8; CHECK:       %dup
9; CHECK:       %true2
10; CHECK:       %false1
11; CHECK:       %false2
12entry:
13  %cond1 = icmp sgt i32 %a, 1
14  br i1 %cond1, label %true1, label %false1, !prof !30
15
16true1:
17  %v1 = load i32, i32* %p, align 4
18  %v2 = add i32 %v1, 2
19  br label %dup
20
21false1:
22  %v3 = load i32, i32* %q, align 4
23  %v4 = sub i32 %v3, 3
24  br label %dup
25
26dup:
27  %v5 = phi i32 [%v2, %true1], [%v4, %false1]
28  %cond2 = icmp sgt i32 %v5, 4
29  br i1 %cond2, label %true2, label %false2, !prof !30
30
31true2:
32  %v6 = xor i32 %v5, %a
33  br label %exit
34
35false2:
36  %v7 = and i32 %v5, %a
37  br label %exit
38
39exit:
40  %v8 = phi i32 [%v6, %true2], [%v7, %false2]
41  ret i32 %v8
42}
43
44; Same code as previous function, but with hot profile count.
45; So %dup should be duplicated into predecessors.
46define i32 @hot(i32 %a, i32* %p, i32* %q) !prof !22 {
47; CHECK-LABEL: hot
48; CHECK:       %entry
49; CHECK:       %true1
50; CHECK:       %false2
51; CHECK:       %false1
52; CHECK:       %true2
53entry:
54  %cond1 = icmp sgt i32 %a, 1
55  br i1 %cond1, label %true1, label %false1, !prof !30
56
57true1:
58  %v1 = load i32, i32* %p, align 4
59  %v2 = add i32 %v1, 2
60  br label %dup
61
62false1:
63  %v3 = load i32, i32* %q, align 4
64  %v4 = sub i32 %v3, 3
65  br label %dup
66
67dup:
68  %v5 = phi i32 [%v2, %true1], [%v4, %false1]
69  %cond2 = icmp sgt i32 %v5, 4
70  br i1 %cond2, label %true2, label %false2, !prof !30
71
72true2:
73  %v6 = xor i32 %v5, %a
74  br label %exit
75
76false2:
77  %v7 = and i32 %v5, %a
78  br label %exit
79
80exit:
81  %v8 = phi i32 [%v6, %true2], [%v7, %false2]
82  ret i32 %v8
83}
84
85
86!llvm.module.flags = !{!1}
87!21 = !{!"function_entry_count", i64 10}
88!22 = !{!"function_entry_count", i64 400}
89
90!30 = !{!"branch_weights", i32 1, i32 1}
91
92!1 = !{i32 1, !"ProfileSummary", !2}
93!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
94!3 = !{!"ProfileFormat", !"InstrProf"}
95!4 = !{!"TotalCount", i64 10000}
96!5 = !{!"MaxCount", i64 10}
97!6 = !{!"MaxInternalCount", i64 1}
98!7 = !{!"MaxFunctionCount", i64 1000}
99!8 = !{!"NumCounts", i64 3}
100!9 = !{!"NumFunctions", i64 3}
101!10 = !{!"DetailedSummary", !11}
102!11 = !{!12, !13, !14}
103!12 = !{i32 10000, i64 100, i32 1}
104!13 = !{i32 999000, i64 100, i32 1}
105!14 = !{i32 999999, i64 1, i32 2}
106