1; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu  -O3 | FileCheck %s
2
3; Function Attrs: uwtable
4; When tail-duplicating during placement, we work backward from blocks with
5; multiple successors. In this case, the block dup1 gets duplicated into dup2
6; and if.then64, and then the block dup2 only gets duplicated into land.lhs.true.
7
8define void @partial_tail_dup(i1 %a1, i1 %a2, i32* %a4, i32* %a5, i8* %a6, i32 %a7) #0 align 2  !prof !1 {
9; CHECK-LABEL: partial_tail_dup:
10; CHECK:        # %bb.0: # %entry
11; CHECK-NEXT:   .p2align 4, 0x90
12; CHECK-NEXT:   .LBB0_1: # %for.cond
13; CHECK-NEXT:   # =>This Inner Loop Header: Depth=1
14; CHECK-NEXT:	  testb	$1, %dil
15; CHECK-NEXT:	  je	.LBB0_3
16; CHECK-NEXT:   # %bb.2: # %land.lhs.true
17; CHECK-NEXT:   # in Loop: Header=BB0_1 Depth=1
18; CHECK-NEXT:	  movl	$10, (%rdx)
19; CHECK-NEXT:	  movl	$2, (%rcx)
20; CHECK-NEXT:	  testl	%r9d, %r9d
21; CHECK-NEXT:	  je	.LBB0_1
22; CHECK-NEXT:	  jmp	.LBB0_8
23; CHECK-NEXT:	  .p2align	4, 0x90
24; CHECK-NEXT:   .LBB0_6: # %dup2
25; CHECK-NEXT:   # in Loop: Header=BB0_1 Depth=1
26; CHECK-NEXT:	  movl	$2, (%rcx)
27; CHECK-NEXT:	  testl	%r9d, %r9d
28; CHECK-NEXT:	  je	.LBB0_1
29; CHECK-NEXT:	  jmp	.LBB0_8
30; CHECK-NEXT:    .p2align 4, 0x90
31; CHECK-NEXT:  .LBB0_3: # %if.end56
32; CHECK-NEXT:    # in Loop: Header=BB0_1 Depth=1
33; CHECK-NEXT:    testb $1, %sil
34; CHECK-NEXT:    je .LBB0_5
35; CHECK-NEXT:  # %bb.4: # %if.then64
36; CHECK-NEXT:    # in Loop: Header=BB0_1 Depth=1
37; CHECK-NEXT:    movb $1, (%r8)
38; CHECK-NEXT:    testl %r9d, %r9d
39; CHECK-NEXT:    je .LBB0_1
40; CHECK-NEXT:    jmp .LBB0_8
41; CHECK-NEXT:  .LBB0_5: # %if.end70
42; CHECK-NEXT:    # in Loop: Header=BB0_1 Depth=1
43; CHECK-NEXT:    movl $12, (%rdx)
44; CHECK-NEXT:    jne .LBB0_6
45; CHECK-NEXT:  .LBB0_8: # %for.end
46; CHECK-NEXT:    retq
47entry:
48  br label %for.cond
49
50for.cond:
51  br i1 %a1, label %land.lhs.true, label %if.end56
52
53land.lhs.true:
54  store i32 10, i32* %a4, align 8
55  br label %dup2
56
57if.end56:
58  br i1 %a2, label %if.then64, label %if.end70, !prof !2
59
60if.then64:
61  store i8 1, i8* %a6, align 1
62  br label %dup1
63
64if.end70:
65  store i32 12, i32* %a4, align 8
66  br i1 %a2, label %dup2, label %for.end
67
68dup2:
69  store i32 2, i32* %a5, align 4
70  br label %dup1
71
72dup1:
73  %val = load i32, i32* %a4, align 8
74  %switch = icmp ult i32 %a7, 1
75  br i1 %switch, label %for.cond, label %for.end, !prof !3
76
77for.end:
78  ret void
79}
80
81attributes #0 = { uwtable }
82
83!1 = !{!"function_entry_count", i64 2}
84!2 = !{!"branch_weights", i32 5, i32 1}
85!3 = !{!"branch_weights", i32 5, i32 1}
86