50 lines · plain
1; REQUIRES: asserts2; RUN: opt -passes='cgscc(inline),instcombine,cgscc(inline)' -S -debug-only=inline -disable-output < %s 2>&1 | FileCheck %s3 4; This test shows that the recursive function will not get simplified5; unless the caller is the function itself, not another different caller.6 7; CHECK: Inlining calls in: test8; CHECK: Function size: 29; CHECK: NOT Inlining (cost=never): recursive, Call: %call = tail call float @inline_rec_true_successor(float %x, float %scale)10 11; CHECK: Inlining calls in: inline_rec_true_successor12; CHECK: Function size: 1013; CHECK: Inlining (cost=-35, threshold=337), Call: %call = tail call float @inline_rec_true_successor(float %fneg, float %scale)14; CHECK: Size after inlining: 1715; CHECK: NOT Inlining (cost=never): noinline function attribute, Call: %call_test = tail call float @test(float %fneg, float %common.ret18.op.i)16; CHECK: NOT Inlining (cost=never): noinline function attribute, Call: %call_test.i = tail call float @test(float %x, float %call.i)17; CHECK: Skipping inlining due to history: inline_rec_true_successor -> inline_rec_true_successor18; CHECK: Updated inlining SCC: (test, inline_rec_true_successor)19 20; CHECK: Inlining calls in: test21; CHECK: Function size: 222; CHECK: Inlining (cost=25, threshold=225), Call: %call = tail call float @inline_rec_true_successor(float %x, float %scale)23; CHECK: Size after inlining: 1024 25define float @test(float %x, float %scale) noinline {26entry:27 %call = tail call float @inline_rec_true_successor(float %x, float %scale)28 ret float %call29}30 31define float @inline_rec_true_successor(float %x, float %scale) {32entry:33 %cmp = fcmp olt float %x, 0.000000e+0034 br i1 %cmp, label %if.then, label %if.end35 36common.ret18: ; preds = %if.then, %if.end37 %common.ret18.op = phi float [ %call_test, %if.then ], [ %mul, %if.end ]38 ret float %common.ret18.op39 40if.then: ; preds = %entry41 %fneg = fneg float %x42 %call = tail call float @inline_rec_true_successor(float %fneg, float %scale)43 %call_test = tail call float @test(float %fneg, float %call)44 br label %common.ret1845 46if.end: ; preds = %entry47 %mul = fmul float %x, %scale48 br label %common.ret1849}50