--- gcc/ChangeLog.orig Tue Apr 23 20:52:37 2002 +++ gcc/ChangeLog Tue Apr 23 22:55:36 2002 @@ -1,3 +1,8 @@ +2002-04-23 Kurt Garloff + + * tree-inline.c: Improve heuristics by using a smoother + function to cut down allowable inlinable size. + 2002-04-23 David O'Brien * config/freebsd.h(OBJECT_FORMAT_ELF): Define. --- gcc/tree-inline.c.orig Tue Apr 23 22:54:17 2002 +++ gcc/tree-inline.c Tue Apr 23 23:24:57 2002 @@ -706,14 +706,32 @@ /* Even if this function is not itself too big to inline, it might be that we've done so much inlining already that we don't want to - risk too much inlining any more and thus halve the acceptable - size. */ + risk too much inlining any more */ if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn) && ((DECL_NUM_STMTS (fn) + (id ? id->inlined_stmts : 0)) * INSNS_PER_STMT - > MAX_INLINE_INSNS) - && DECL_NUM_STMTS (fn) * INSNS_PER_STMT > MAX_INLINE_INSNS / 4) - inlinable = 0; - + > MAX_INLINE_INSNS * 128)) + inlinable = 0; + /* If we did not hit the extreme limit 128*MAX_INLINE_INSNS by recursion, + and we did not hit the limit for a single function (MAX_INLINE_INSNS/2) + but we are above the recursive throttling threshold (MAX_INLINE_INSNS), + we use a limit that descreases linearly with the already inlined + code. We always allow very small funtions (13 statements) to be inlined. + Value (13*INSNS_PER_STMT) found by numerous experiments in 3.0.x with + C++ code */ + else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn) + && ((DECL_NUM_STMTS (fn) + (id ? id->inlined_stmts : 0)) + * INSNS_PER_STMT > MAX_INLINE_INSNS) + && DECL_NUM_STMTS (fn) > 13) { + /* Use a linear function with a slope of -0.03125 + we could also use an int approx. of sqrt or similar things */ + signed int max_curr = MAX_INLINE_INSNS/2 + - (( DECL_NUM_STMTS (fn) + (id ? id->inlined_stmts : 0)) + * INSNS_PER_STMT - MAX_INLINE_INSNS) / 32; + + if ((signed int)(DECL_NUM_STMTS (fn) * INSNS_PER_STMT) > max_curr) + inlinable = 0; + } + if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn)) inlinable = 0; @@ -968,7 +986,8 @@ /* Our function now has more statements than it did before. */ DECL_NUM_STMTS (VARRAY_TREE (id->fns, 0)) += DECL_NUM_STMTS (fn); - id->inlined_stmts += DECL_NUM_STMTS (fn); + /* For accounting, subtract one for the saved call/ret */ + id->inlined_stmts += DECL_NUM_STMTS (fn) - 1; /* Recurse into the body of the just inlined function. */ expand_calls_inline (inlined_body, id);