1 ; RUN: opt < %s -inline -inline-threshold=20 -S | FileCheck %s
3 define internal i32 @callee1(i32 %A, i32 %B) {
8 define i32 @caller1() {
9 ; CHECK: define i32 @caller1
10 ; CHECK-NEXT: ret i32 3
12 %X = call i32 @callee1( i32 10, i32 3 )
16 define i32 @caller2() {
17 ; Check that we can constant-prop through instructions after inlining callee21
18 ; to get constants in the inlined callsite to callee22.
19 ; FIXME: Currently, the threshold is fixed at 20 because we don't perform
20 ; *recursive* cost analysis to realize that the nested call site will definitely
21 ; inline and be cheap. We should eventually do that and lower the threshold here
25 ; CHECK-NOT: call void @callee2
28 %x = call i32 @callee21(i32 42, i32 48)
32 define i32 @callee21(i32 %x, i32 %y) {
34 %result = call i32 @callee22(i32 %sub)
40 define i32 @callee22(i32 %x) {
41 %icmp = icmp ugt i32 %x, 42
42 br i1 %icmp, label %bb.true, label %bb.false
44 ; This block musn't be counted in the inline cost.
59 define i32 @caller3() {
60 ; Check that even if the expensive path is hidden behind several basic blocks,
61 ; it doesn't count toward the inline cost when constant-prop proves those paths
69 %x = call i32 @callee3(i32 42, i32 48)
73 define i32 @callee3(i32 %x, i32 %y) {
75 %icmp = icmp ugt i32 %sub, 42
76 br i1 %icmp, label %bb.true, label %bb.false
79 %icmp2 = icmp ult i32 %sub, 64
80 br i1 %icmp2, label %bb.true.true, label %bb.true.false
83 ; This block musn't be counted in the inline cost.
95 ; This block musn't be counted in the inline cost.
107 %result = phi i32 [ %x8, %bb.true.true ], [ %y8, %bb.true.false ]