166 lines · plain
1; RUN: opt < %s -mtriple=systemz-unknown -mcpu=z15 -passes='cgscc(inline)' -disable-output \2; RUN: -debug-only=inline,systemztti 2>&1 | FileCheck %s3; REQUIRES: asserts4 5; Check that the inlining threshold is incremented for a function using an6; argument only as a memcpy source.7;8; CHECK: Inlining calls in: root_function9; CHECK: Inlining {{.*}} Call: call void @leaf_function_A(ptr %Dst)10; CHECK: ++ SZTTI Adding inlining bonus: 100011; CHECK: Inlining {{.*}} Call: call void @leaf_function_B(ptr %Dst, ptr %Src)12 13define void @leaf_function_A(ptr %Dst) {14entry:15 call void @llvm.memcpy.p0.p0.i64(ptr %Dst, ptr undef, i64 16, i1 false)16 ret void17}18 19define void @leaf_function_B(ptr %Dst, ptr %Src) {20entry:21 call void @llvm.memcpy.p0.p0.i64(ptr %Dst, ptr %Src, i64 16, i1 false)22 ret void23}24 25define void @root_function(ptr %Dst, ptr %Src) {26entry:27 call void @leaf_function_A(ptr %Dst)28 call void @leaf_function_B(ptr %Dst, ptr %Src)29 ret void30}31 32declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)33 34; Check that the inlining threshold is incremented in case of multiple35; accesses of a global variable by both caller and callee (which is true here36; after the first call is inlined).37;38; CHECK: Inlining calls in: Caller139; CHECK: ++ SZTTI Adding inlining bonus: 100040 41@GlobV = external global i3242 43define i64 @Caller1(i1 %cond1, i32 %0) #0 {44entry:45 br i1 %cond1, label %sw.bb3437, label %fake_end46 47common.ret: ; preds = %fake_end, %sw.bb343748 ret i64 049 50sw.bb3437: ; preds = %entry51 %call34652 = call i32 @Callee1(ptr null, i32 %0)52 br label %common.ret53 54fake_end: ; preds = %entry55 %call57981 = call i32 @Callee1(ptr null, i32 0)56 br label %common.ret57}58 59define i32 @Callee1(ptr %rex, i32 %parenfloor) #0 {60entry:61 %cmp21 = icmp slt i32 %parenfloor, 062 br i1 %cmp21, label %for.body, label %for.end63 64common.ret: ; preds = %for.end, %for.body65 ret i32 066 67for.body: ; preds = %entry68 %0 = load i32, ptr @GlobV, align 469 %inc = or i32 %0, 170 store i32 %inc, ptr @GlobV, align 471 store i64 0, ptr %rex, align 872 %1 = load i32, ptr @GlobV, align 473 %inc28 = or i32 %1, 174 store i32 %inc28, ptr @GlobV, align 475 store i64 0, ptr %rex, align 876 %2 = load i32, ptr @GlobV, align 477 %inc35 = or i32 %2, 178 store i32 %inc35, ptr @GlobV, align 479 store i32 0, ptr %rex, align 880 br label %common.ret81 82for.end: ; preds = %entry83 store i32 0, ptr @GlobV, align 484 store i32 0, ptr %rex, align 885 %3 = load i32, ptr @GlobV, align 486 %inc42 = or i32 %3, 187 store i32 %inc42, ptr @GlobV, align 488 store i32 0, ptr %rex, align 889 %4 = load i32, ptr @GlobV, align 490 %inc48 = or i32 %4, 191 store i32 %inc48, ptr @GlobV, align 492 br label %common.ret93}94 95; Check that the inlining threshold is incremented for a function that is96; accessing an alloca of the caller multiple times.97;98; CHECK: Inlining calls in: Caller299; CHECK: ++ SZTTI Adding inlining bonus: 550100 101define i1 @Caller2() {102entry:103 %A = alloca [80 x i64], align 8104 call void @Callee2(ptr %A)105 ret i1 false106}107 108define void @Callee2(ptr nocapture readonly %Arg) {109entry:110 %nonzero = getelementptr i8, ptr %Arg, i64 48111 %0 = load i32, ptr %nonzero, align 8112 %tobool1.not = icmp eq i32 %0, 0113 br i1 %tobool1.not, label %if.else38, label %if.then2114 115if.then2: ; preds = %entry116 %1 = load i32, ptr %Arg, align 4117 %tobool4.not = icmp eq i32 %1, 0118 br i1 %tobool4.not, label %common.ret, label %if.then5119 120if.then5: ; preds = %if.then2121 %2 = load double, ptr %Arg, align 8122 %slab_den = getelementptr i8, ptr %Arg, i64 24123 %3 = load double, ptr %slab_den, align 8124 %mul = fmul double %2, %3125 %cmp = fcmp olt double %mul, 0.000000e+00126 br i1 %cmp, label %common.ret, label %if.end55127 128common.ret: ; preds = %if.end100, %if.else79, %if.end55, %if.else38, %if.then5, %if.then2129 ret void130 131if.else38: ; preds = %entry132 %4 = load double, ptr %Arg, align 8133 %cmp52 = fcmp ogt double %4, 0.000000e+00134 br i1 %cmp52, label %common.ret, label %if.end55135 136if.end55: ; preds = %if.else38, %if.then5137 %arrayidx57 = getelementptr i8, ptr %Arg, i64 52138 %5 = load i32, ptr %arrayidx57, align 4139 %tobool58.not = icmp eq i32 %5, 0140 br i1 %tobool58.not, label %common.ret, label %if.then59141 142if.then59: ; preds = %if.end55143 %arrayidx61 = getelementptr i8, ptr %Arg, i64 64144 %6 = load i32, ptr %arrayidx61, align 4145 %tobool62.not = icmp eq i32 %6, 0146 br i1 %tobool62.not, label %if.else79, label %if.end100147 148if.else79: ; preds = %if.then59149 %arrayidx84 = getelementptr i8, ptr %Arg, i64 8150 %7 = load double, ptr %arrayidx84, align 8151 %arrayidx87 = getelementptr i8, ptr %Arg, i64 32152 %8 = load double, ptr %arrayidx87, align 8153 %mul88 = fmul double %7, %8154 %9 = fcmp olt double %mul88, 0.000000e+00155 br i1 %9, label %common.ret, label %if.end100156 157if.end100: ; preds = %if.else79, %if.then59158 %arrayidx151 = getelementptr i8, ptr %Arg, i64 16159 %10 = load double, ptr %arrayidx151, align 8160 %arrayidx154 = getelementptr i8, ptr %Arg, i64 40161 %11 = load double, ptr %arrayidx154, align 8162 %mul155 = fmul double %10, %11163 %cmp181 = fcmp olt double %mul155, 0.000000e+00164 br label %common.ret165}166