1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
4 @gvar = external global i32
6 ; dupbb has two predecessors, p1 and p2. p1 is hot, p2 is cold. So dupbb
7 ; should be placed after p1, and not duplicated into p2.
11 ; CHECK: .LBB0_4: # %dupbb
15 define void @test1(ptr %p) !prof !1 {
20 %call = call zeroext i1 @a()
21 br i1 %call, label %p1, label %p2, !prof !2
32 %cond = icmp eq ptr @gvar, %p
33 br i1 %cond, label %header, label %latch, !prof !3
36 %call3 = call zeroext i1 @a()
37 br i1 %call3, label %header, label %end, !prof !2
44 ; dupbb has four predecessors p1, p2, p3 and p4. p1 and p2 are hot, p3 and p4
45 ; are cold. So dupbb should be placed after p1, duplicated into p2. p3 and p4
46 ; should jump to dupbb.
50 ; CHECK: .LBB1_8: # %dupbb
63 define void @test2(ptr %p) !prof !1 {
68 %call = call zeroext i1 @a()
69 br i1 %call, label %bb1, label %bb2, !prof !2
72 %call1 = call zeroext i1 @a()
73 br i1 %call1, label %p1, label %p2, !prof !4
76 %call2 = call zeroext i1 @a()
77 br i1 %call2, label %p3, label %p4, !prof !4
96 %cond = icmp eq ptr @gvar, %p
97 br i1 %cond, label %bb3, label %bb4, !prof !4
104 %call4 = call zeroext i1 @a()
105 br i1 %call4, label %header, label %latch, !prof !3
108 %call3 = call zeroext i1 @a()
109 br i1 %call3, label %header, label %end, !prof !2
116 ; dupbb has three predecessors p1, p2 and p3. p3 has two successors, so dupbb
117 ; can't be duplicated into p3, but it should not block it to be duplicated into
118 ; other predecessors.
122 ; CHECK: .LBB2_6: # %dupbb
133 define void @test3(ptr %p) !prof !1 {
138 %call = call zeroext i1 @a()
139 br i1 %call, label %bb1, label %p3, !prof !2
142 %call1 = call zeroext i1 @a()
143 br i1 %call1, label %p1, label %p2, !prof !4
154 %call2 = call zeroext i1 @a()
155 br i1 %call2, label %dupbb, label %bb4, !prof !4
158 %cond = icmp eq ptr @gvar, %p
159 br i1 %cond, label %bb3, label %bb4, !prof !4
166 %call4 = call zeroext i1 @a()
167 br i1 %call4, label %header, label %latch, !prof !3
170 %call3 = call zeroext i1 @a()
171 br i1 %call3, label %header, label %end, !prof !2
177 declare zeroext i1 @a()
184 !1 = !{!"function_entry_count", i64 1000}
185 !2 = !{!"branch_weights", i32 100, i32 1}
186 !3 = !{!"branch_weights", i32 1, i32 100}
187 !4 = !{!"branch_weights", i32 60, i32 40}