1; RUN: llc -O3 -o - %s | FileCheck %s
2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-unknown-linux-gnu"
4
5declare void @effect(i32);
6
7; After the loop gets laid out, loop.end is the only successor, but can't be
8; laid out because of the CFG dependency from top.fakephi. The calculations show
9; that it isn't profitable to tail-duplicate in this case, because of the
10; effects on fallthrough from %loop.end
11; CHECK-LABEL: {{^}}no_successor_still_no_taildup:
12; CHECK: %entry
13; CHECK: %loop.top
14; CHECK: %loop.latch
15; CHECK: %top.fakephi
16; CHECK: %loop.end
17; CHECK: %false
18; CHECK: %ret
19define void @no_successor_still_no_taildup (i32 %count, i32 %key) {
20entry:
21  br label %loop.top
22
23loop.top:
24  %i.loop.top = phi i32 [ %count, %entry ], [ %i.latch, %loop.latch ]
25  %cmp.top = icmp eq i32 %i.loop.top, %key
26  call void @effect(i32 0)
27  br i1 %cmp.top, label %top.fakephi, label %loop.latch, !prof !1
28
29loop.latch:
30  %i.latch = sub i32 %i.loop.top, 1
31  %cmp.latch = icmp eq i32 %i.latch, 0
32  call void @effect(i32 1)
33  br i1 %cmp.top, label %loop.top, label %loop.end, !prof !2
34
35top.fakephi:
36  call void @effect(i32 2)
37  br label %loop.end
38
39loop.end:
40  %cmp.end = icmp eq i32 %count, 0
41  br i1 %cmp.end, label %ret, label %false, !prof !3
42
43false:
44  call void @effect(i32 4)
45  br label %ret
46
47ret:
48  ret void
49}
50
51!1 = !{!"branch_weights", i32 1, i32 1}
52!2 = !{!"branch_weights", i32 5, i32 1}
53!3 = !{!"branch_weights", i32 1, i32 2}
54