1 ; RUN: opt -S -passes=partial-inliner -min-block-execution=1 -skip-partial-inlining-cost-analysis < %s | FileCheck %s
2 ; Require a dummy block (if.then.b) as successor to if.then due to PI requirement
3 ; of region containing more than one BB.
4 define signext i32 @bar(i32 signext %value, i32 signext %ub) #0 !prof !30 {
6 %value.addr = alloca i32, align 4
7 %ub.addr = alloca i32, align 4
8 %sum = alloca i32, align 4
9 %i = alloca i32, align 4
10 store i32 %value, ptr %value.addr, align 4
11 store i32 %ub, ptr %ub.addr, align 4
12 store i32 0, ptr %sum, align 4
13 store i32 0, ptr %i, align 4
16 for.cond: ; preds = %for.inc, %entry
17 %0 = load i32, ptr %i, align 4
18 %1 = load i32, ptr %ub.addr, align 4
19 %cmp = icmp slt i32 %0, %1
20 br i1 %cmp, label %for.body, label %for.cond2, !prof !31
22 for.body: ; preds = %for.cond
23 %2 = load i32, ptr %value.addr, align 4
24 %rem = srem i32 %2, 20
25 %cmp1 = icmp eq i32 %rem, 0
26 br i1 %cmp1, label %if.then, label %if.else, !prof !32
28 if.then: ; preds = %for.body
29 %3 = load i32, ptr %value.addr, align 4
30 %4 = load i32, ptr %i, align 4
31 %mul = mul nsw i32 %4, 5
32 %add = add nsw i32 %3, %mul
33 %5 = load i32, ptr %sum, align 4
34 %add2 = add nsw i32 %5, %add
35 store i32 %add2, ptr %sum, align 4
38 if.then.b: ; preds = %if.then
41 if.else: ; preds = %for.body
42 %6 = load i32, ptr %value.addr, align 4
43 %7 = load i32, ptr %i, align 4
44 %sub = sub nsw i32 %6, %7
45 %8 = load i32, ptr %sum, align 4
46 %add3 = add nsw i32 %8, %sub
47 store i32 %add3, ptr %sum, align 4
50 if.end: ; preds = %if.else, %if.then
53 for.inc: ; preds = %if.end
54 %9 = load i32, ptr %i, align 4
55 %inc = add nsw i32 %9, 1
56 store i32 %inc, ptr %i, align 4
59 for.cond2: ; preds = %for.cond
60 %10 = load i32, ptr %i, align 4
61 %11 = load i32, ptr %ub.addr, align 4
62 %cmp2 = icmp slt i32 %10, %11
63 br i1 %cmp2, label %for.body2, label %for.end, !prof !31
65 for.body2: ; preds = %for.cond2
66 %12 = load i32, ptr %value.addr, align 4
67 %rem2 = srem i32 %12, 20
68 %cmp3 = icmp eq i32 %rem2, 0
69 br i1 %cmp3, label %if.then2, label %if.else2, !prof !32
71 if.then2: ; preds = %for.body2
72 %13 = load i32, ptr %value.addr, align 4
73 %14 = load i32, ptr %i, align 4
74 %mul2 = mul nsw i32 %14, 5
75 %add4 = add nsw i32 %13, %mul2
76 %15 = load i32, ptr %sum, align 4
77 %add5 = add nsw i32 %15, %add4
78 store i32 %add5, ptr %sum, align 4
81 if.then2.b: ; preds = %if.then2
84 if.else2: ; preds = %for.body2
85 %16 = load i32, ptr %value.addr, align 4
86 %17 = load i32, ptr %i, align 4
87 %sub2 = sub nsw i32 %16, %17
88 %18 = load i32, ptr %sum, align 4
89 %add6 = add nsw i32 %18, %sub2
90 store i32 %add6, ptr %sum, align 4
93 if.end2: ; preds = %if.else2, %if.then2
96 for.inc2: ; preds = %if.end2
97 %19 = load i32, ptr %i, align 4
98 %inc2 = add nsw i32 %19, 1
99 store i32 %inc2, ptr %i, align 4
102 for.end: ; preds = %for.cond2
103 callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "!i,~{dirflag},~{fpsr},~{flags}"()
104 to label %asm.fallthrough [label %l_yes]
105 asm.fallthrough: ; preds = %for.end
109 %20 = load i32, ptr %sum, align 4
113 define signext i32 @foo(i32 signext %value, i32 signext %ub) #0 !prof !30 {
115 ; CHECK-NOT: call signext i32 @bar
116 ; CHECK: codeRepl1.i:
117 ; CHECK: call void @bar.1.if.then
119 ; CHECK: call void @bar.1.if.then2
121 %value.addr = alloca i32, align 4
122 %ub.addr = alloca i32, align 4
123 store i32 %value, ptr %value.addr, align 4
124 store i32 %ub, ptr %ub.addr, align 4
125 %0 = load i32, ptr %value.addr, align 4
126 %1 = load i32, ptr %ub.addr, align 4
127 %call = call signext i32 @bar(i32 signext %0, i32 signext %1)
131 ; CHECK-LABEL: define internal void @bar.1.if.then2
135 ; CHECK-LABEL: define internal void @bar.1.if.then
139 !llvm.module.flags = !{!0, !1, !2}
142 !0 = !{i32 1, !"wchar_size", i32 4}
143 !1 = !{i32 7, !"PIC Level", i32 2}
144 !2 = !{i32 1, !"ProfileSummary", !3}
145 !3 = !{!4, !5, !6, !7, !8, !9, !10, !11}
146 !4 = !{!"ProfileFormat", !"InstrProf"}
147 !5 = !{!"TotalCount", i64 103}
148 !6 = !{!"MaxCount", i64 100}
149 !7 = !{!"MaxInternalCount", i64 1}
150 !8 = !{!"MaxFunctionCount", i64 100}
151 !9 = !{!"NumCounts", i64 5}
152 !10 = !{!"NumFunctions", i64 3}
153 !11 = !{!"DetailedSummary", !12}
154 !12 = !{!13, !14, !15, !16, !17, !18, !18, !19, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28}
155 !13 = !{i32 10000, i64 100, i32 1}
156 !14 = !{i32 100000, i64 100, i32 1}
157 !15 = !{i32 200000, i64 100, i32 1}
158 !16 = !{i32 300000, i64 100, i32 1}
159 !17 = !{i32 400000, i64 100, i32 1}
160 !18 = !{i32 500000, i64 100, i32 1}
161 !19 = !{i32 600000, i64 100, i32 1}
162 !20 = !{i32 700000, i64 100, i32 1}
163 !21 = !{i32 800000, i64 100, i32 1}
164 !22 = !{i32 900000, i64 100, i32 1}
165 !23 = !{i32 950000, i64 100, i32 1}
166 !24 = !{i32 990000, i64 1, i32 4}
167 !25 = !{i32 999000, i64 1, i32 4}
168 !26 = !{i32 999900, i64 1, i32 4}
169 !27 = !{i32 999990, i64 1, i32 4}
170 !28 = !{i32 999999, i64 1, i32 4}
171 !29 = !{!"clang version 6.0.0 (123456)"}
172 !30 = !{!"function_entry_count", i64 2}
173 !31 = !{!"branch_weights", i32 100, i32 1}
174 !32 = !{!"branch_weights", i32 0, i32 100}