This fixes PR51519. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard. 2011-12-13 Richard Guenther <rguent...@suse.de> PR tree-optimization/51519 * ipa-inline.c (edge_badness): Use edge growth in non-guessed branch probability case as well. * gcc.dg/pr51519.c: New testcase. Index: gcc/ipa-inline.c =================================================================== --- gcc/ipa-inline.c (revision 182220) +++ gcc/ipa-inline.c (working copy) @@ -861,7 +861,7 @@ edge_badness (struct cgraph_edge *edge, else { int nest = MIN (inline_edge_summary (edge)->loop_depth, 8); - badness = estimate_growth (callee) * 256; + badness = growth * 256; /* Decrease badness if call is nested. */ if (badness > 0) Index: gcc/testsuite/gcc.dg/pr51519.c =================================================================== --- gcc/testsuite/gcc.dg/pr51519.c (revision 0) +++ gcc/testsuite/gcc.dg/pr51519.c (revision 0) @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-guess-branch-probability -findirect-inlining" } */ + +void fe (void); +int i; + +static inline void +FX (void (*f) (void)) +{ + fe (); + (*f) (); +} + +static inline void +f4 () +{ + if (i) + FX (fe); +} + +static inline void +f3 (void) +{ + f4 (); + if (i) + FX (f4); +} + +static inline void +f2 (void) +{ + FX (&f3); +} + +void +f1 (void) +{ + FX (&f2); +}