http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60315
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- Hmm, ok - it is supposed to only account for the extra call edges in the inlined bodies. The actual issue seems to be Deciding on inlining of small functions. Starting with size 114. Enqueueing calls in Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/14. Enqueueing calls in Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13. Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 enqueuing call Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/14, badness -1073741826 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/9 Known to be false: not inlined, op1 != 2, op1 changed size:0 time:0 enqueuing call Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/10, badness -1073741827 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)1u]/5 Known to be false: not inlined, op1 != 1, op1 changed size:0 time:0 ... Considering Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/9 with 27 size to be inlined into Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 in t.C:21 Estimated growth after inlined into all is +27 insns. Estimated badness is -1073741827, frequency 0.16. Badness calculation for Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/10 size growth -3, time 0 inline hints: in_scc declared_inline -1073741827: Growth -3 <= 0 Processing frequency Test<scale>::Test(Scale) [with Scale scale = (Scale)2u] Called by Test<scale>::Test(Scale) [with Scale scale = (Scale)3u] that is normal or hot Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/2 Known to be false: not inlined, op1 != 0, op1 changed size:0 time:0 enqueuing call Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/30 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/3, badness -1073741827 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)1u]/5 Known to be false: not inlined, op1 != 1, op1 changed size:0 time:0 enqueuing call Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/30 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)1u]/6, badness -1073741827 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/9 Known to be false: not inlined, op1 != 2, op1 changed size:0 time:0 enqueuing call Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/30 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/10, badness -1073741827 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 enqueuing call Test<scale>::Test(Scale) [with Scale scale = (Scale)2u]/30 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/14, badness -1073741826 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 Inlined into Test<scale>::Test(Scale) [with Scale scale = (Scale)3u] which now has time 13 and size 24,net change of -3. New minimal size reached: 111 Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)1u]/5 Known to be false: not inlined, op1 != 1, op1 changed size:0 time:0 Considering Test<scale>::Test(Scale) [with Scale scale = (Scale)1u]/5 with 27 size to be inlined into Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/2 in t.C:20 Estimated growth after inlined into all is +27 insns. Estimated badness is -1073741827, frequency 0.12. Badness calculation for Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/2 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)1u]/6 size growth -3, time 0 inline hints: declared_inline -1073741827: Growth -3 <= 0 ... so we are inlining all over the place but don't really arrive at a point where no further useful inlining is left and inlining never has a growth effect in our theory and we continue to think that we shrink the overall unit by further inlining. Meanwhile the cgraph is full of millions of calls (but estimated to be never reached?): Considering Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/2 with 24 size to be inlined into Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/76 in t.C:19 Estimated growth after inlined into all is +24 insns. Estimated badness is -1073741827, frequency 0.00. Badness calculation for Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/76 -> Test<scale>::Test(Scale) [with Scale scale = (Scale)0u]/3 size growth -3, time 0 inline hints: in_scc declared_inline -1073741827: Growth -3 <= 0 not inlining recursively: recursive call is cold Estimating body: Test<scale>::Test(Scale) [with Scale scale = (Scale)3u]/13 Known to be false: not inlined, op1 != 3, op1 changed size:0 time:0 I wonder if we can somehow prune those edges we don't consider inlining early ...