1 ; RUN: opt < %s -mtriple=systemz-unknown -mcpu=z15 -passes='cgscc(inline)' -disable-output \
2 ; RUN: -debug-only=inline,systemztti 2>&1 | FileCheck %s
5 ; Check that the inlining threshold is incremented for a function using an
6 ; argument only as a memcpy source.
8 ; CHECK: Inlining calls in: root_function
9 ; CHECK: Inlining {{.*}} Call: call void @leaf_function_A(ptr %Dst)
10 ; CHECK: ++ SZTTI Adding inlining bonus: 1000
11 ; CHECK: Inlining {{.*}} Call: call void @leaf_function_B(ptr %Dst, ptr %Src)
13 define void @leaf_function_A(ptr %Dst) {
15 call void @llvm.memcpy.p0.p0.i64(ptr %Dst, ptr undef, i64 16, i1 false)
19 define void @leaf_function_B(ptr %Dst, ptr %Src) {
21 call void @llvm.memcpy.p0.p0.i64(ptr %Dst, ptr %Src, i64 16, i1 false)
25 define void @root_function(ptr %Dst, ptr %Src) {
27 call void @leaf_function_A(ptr %Dst)
28 call void @leaf_function_B(ptr %Dst, ptr %Src)
32 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
34 ; Check that the inlining threshold is incremented in case of multiple
35 ; accesses of a global variable by both caller and callee (which is true here
36 ; after the first call is inlined).
38 ; CHECK: Inlining calls in: Caller1
39 ; CHECK: ++ SZTTI Adding inlining bonus: 1000
41 @GlobV = external global i32
43 define i64 @Caller1(i1 %cond1, i32 %0) #0 {
45 br i1 %cond1, label %sw.bb3437, label %fake_end
47 common.ret: ; preds = %fake_end, %sw.bb3437
50 sw.bb3437: ; preds = %entry
51 %call34652 = call i32 @Callee1(ptr null, i32 %0)
54 fake_end: ; preds = %entry
55 %call57981 = call i32 @Callee1(ptr null, i32 0)
59 define i32 @Callee1(ptr %rex, i32 %parenfloor) #0 {
61 %cmp21 = icmp slt i32 %parenfloor, 0
62 br i1 %cmp21, label %for.body, label %for.end
64 common.ret: ; preds = %for.end, %for.body
67 for.body: ; preds = %entry
68 %0 = load i32, ptr @GlobV, align 4
70 store i32 %inc, ptr @GlobV, align 4
71 store i64 0, ptr %rex, align 8
72 %1 = load i32, ptr @GlobV, align 4
74 store i32 %inc28, ptr @GlobV, align 4
75 store i64 0, ptr %rex, align 8
76 %2 = load i32, ptr @GlobV, align 4
78 store i32 %inc35, ptr @GlobV, align 4
79 store i32 0, ptr %rex, align 8
82 for.end: ; preds = %entry
83 store i32 0, ptr @GlobV, align 4
84 store i32 0, ptr %rex, align 8
85 %3 = load i32, ptr @GlobV, align 4
87 store i32 %inc42, ptr @GlobV, align 4
88 store i32 0, ptr %rex, align 8
89 %4 = load i32, ptr @GlobV, align 4
91 store i32 %inc48, ptr @GlobV, align 4
95 ; Check that the inlining threshold is incremented for a function that is
96 ; accessing an alloca of the caller multiple times.
98 ; CHECK: Inlining calls in: Caller2
99 ; CHECK: ++ SZTTI Adding inlining bonus: 550
101 define i1 @Caller2() {
103 %A = alloca [80 x i64], align 8
104 call void @Callee2(ptr %A)
108 define void @Callee2(ptr nocapture readonly %Arg) {
110 %nonzero = getelementptr i8, ptr %Arg, i64 48
111 %0 = load i32, ptr %nonzero, align 8
112 %tobool1.not = icmp eq i32 %0, 0
113 br i1 %tobool1.not, label %if.else38, label %if.then2
115 if.then2: ; preds = %entry
116 %1 = load i32, ptr %Arg, align 4
117 %tobool4.not = icmp eq i32 %1, 0
118 br i1 %tobool4.not, label %common.ret, label %if.then5
120 if.then5: ; preds = %if.then2
121 %2 = load double, ptr %Arg, align 8
122 %slab_den = getelementptr i8, ptr %Arg, i64 24
123 %3 = load double, ptr %slab_den, align 8
124 %mul = fmul double %2, %3
125 %cmp = fcmp olt double %mul, 0.000000e+00
126 br i1 %cmp, label %common.ret, label %if.end55
128 common.ret: ; preds = %if.end100, %if.else79, %if.end55, %if.else38, %if.then5, %if.then2
131 if.else38: ; preds = %entry
132 %4 = load double, ptr %Arg, align 8
133 %cmp52 = fcmp ogt double %4, 0.000000e+00
134 br i1 %cmp52, label %common.ret, label %if.end55
136 if.end55: ; preds = %if.else38, %if.then5
137 %arrayidx57 = getelementptr i8, ptr %Arg, i64 52
138 %5 = load i32, ptr %arrayidx57, align 4
139 %tobool58.not = icmp eq i32 %5, 0
140 br i1 %tobool58.not, label %common.ret, label %if.then59
142 if.then59: ; preds = %if.end55
143 %arrayidx61 = getelementptr i8, ptr %Arg, i64 64
144 %6 = load i32, ptr %arrayidx61, align 4
145 %tobool62.not = icmp eq i32 %6, 0
146 br i1 %tobool62.not, label %if.else79, label %if.end100
148 if.else79: ; preds = %if.then59
149 %arrayidx84 = getelementptr i8, ptr %Arg, i64 8
150 %7 = load double, ptr %arrayidx84, align 8
151 %arrayidx87 = getelementptr i8, ptr %Arg, i64 32
152 %8 = load double, ptr %arrayidx87, align 8
153 %mul88 = fmul double %7, %8
154 %9 = fcmp olt double %mul88, 0.000000e+00
155 br i1 %9, label %common.ret, label %if.end100
157 if.end100: ; preds = %if.else79, %if.then59
158 %arrayidx151 = getelementptr i8, ptr %Arg, i64 16
159 %10 = load double, ptr %arrayidx151, align 8
160 %arrayidx154 = getelementptr i8, ptr %Arg, i64 40
161 %11 = load double, ptr %arrayidx154, align 8
162 %mul155 = fmul double %10, %11
163 %cmp181 = fcmp olt double %mul155, 0.000000e+00