public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/47663] New: Very simple wrapper not inlined
@ 2011-02-09 15:52 rguenth at gcc dot gnu.org
  2011-02-09 16:20 ` [Bug middle-end/47663] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-09 15:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47663

           Summary: Very simple wrapper not inlined
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: rguenth@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org
                CC: hubicka@gcc.gnu.org


int foo0();
inline void bar0() { foo0(); }
void foobar() { bar0(); }

is not inlined at -O[12] because

;; Function foobar (foobar)

Analyzing function body size: foobar
  freq:  1000 size:  1 time: 10 bar0 ();
  freq:  1000 size:  1 time:  2 return;
    will eliminated by inlining
Overall function body time: 12-2 size: 4-3
With function call overhead time: 12-12 size: 4-4

;; Function bar0 (bar0)

Analyzing function body size: bar0
  freq:  1000 size:  2 time: 11 foo0 ();
  freq:  1000 size:  1 time:  2 return;
    will eliminated by inlining
Overall function body time: 13-2 size: 5-3
With function call overhead time: 13-12 size: 5-4

and thus

;; Function foobar (foobar)

Considering inline candidate bar0.
Not inlining: code size would grow by 1.


for some reason an unused return value in a call has a cost.

I have a patch.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/47663] Very simple wrapper not inlined
  2011-02-09 15:52 [Bug middle-end/47663] New: Very simple wrapper not inlined rguenth at gcc dot gnu.org
@ 2011-02-09 16:20 ` rguenth at gcc dot gnu.org
  2011-02-10 13:08 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-09 16:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47663

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.02.09 16:11:54
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-09 16:11:54 UTC ---
It's actually not that simple as we have to match the caller / callee side
of costs to not run into negative limits.  We could disregard returns in
registers completely or account for the cost (benefit) by not accounting
the return statement at all.  It would at least be nice to have a way
to positively bias inlining of

  struct X { ...large... } foo();

at a call-site that does not use the return value.  Currently call-sites
that do use the return value get a benefit as well (independent of, for
example, if the return slot is passed by reference).  Not handling the
return type at all would at least remove that false benefit accounting.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/47663] Very simple wrapper not inlined
  2011-02-09 15:52 [Bug middle-end/47663] New: Very simple wrapper not inlined rguenth at gcc dot gnu.org
  2011-02-09 16:20 ` [Bug middle-end/47663] " rguenth at gcc dot gnu.org
@ 2011-02-10 13:08 ` rguenth at gcc dot gnu.org
  2011-02-22 14:28 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-10 13:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47663

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-10 13:05:14 UTC ---
We want to inline all cases of

int foo0();
void bar0() { foo0(); }
void foobar0() { bar0(); }

void foo1();
void bar1() { foo1(); }
void foobar1() { bar1(); }

int foo2();
int bar2() { return foo2(); }
void foobar2() { bar2(); }

int foo3();
int bar3() { return foo3(); }
void foobar3() { return bar3(); }

int bar4() { return 0; }
void foobar4() { bar4(); }

int bar5() { return 0; }
void foobar5() { return bar5(); }

and corresponding versions that return an aggregate at
-O -finline-small-functions --param early-inlining-insns=0
(thus, with strict non-growth limits).

To achieve that we probably need to track whether a callgraph-edge
caller uses its return value (or even better, store the call cost
in the cgraph-edge instead of computing it based on the type of
the callee).


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/47663] Very simple wrapper not inlined
  2011-02-09 15:52 [Bug middle-end/47663] New: Very simple wrapper not inlined rguenth at gcc dot gnu.org
  2011-02-09 16:20 ` [Bug middle-end/47663] " rguenth at gcc dot gnu.org
  2011-02-10 13:08 ` rguenth at gcc dot gnu.org
@ 2011-02-22 14:28 ` rguenth at gcc dot gnu.org
  2011-04-06  8:51 ` rguenth at gcc dot gnu.org
  2011-04-06 10:11 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-22 14:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47663

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-22 13:47:18 UTC ---
Author: rguenth
Date: Tue Feb 22 13:47:15 2011
New Revision: 170400

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170400
Log:
2011-02-22  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/47663
    * cgraph.h (struct cgraph_edge): Add call_stmt_size and
    call_stmt_time fields.
    (cgraph_edge_inlinable_p): Declare.
    (cgraph_edge_recursive_p): New inline function.
    * cgraph.c (cgraph_create_edge_1): Initialize call_stmt_size.
    (cgraph_clone_edge): Copy it.
    * ipa-inline.c (cgraph_estimate_edge_time): New function.
    Account for call stmt time.
    (cgraph_estimate_time_after_inlining): Take edge argument.
    (cgraph_estimate_edge_growth): Account call stmt size.
    (cgraph_estimate_size_after_inlining): Take edge argument.
    (cgraph_mark_inline_edge): Adjust.
    (cgraph_check_inline_limits): Likewise.
    (cgraph_recursive_inlining_p): Remove.
    (cgraph_edge_badness): Use cgraph_edge_recursive_p.
    (cgraph_decide_recursive_inlining): Take edge argument and
    adjust.
    (cgraph_decide_inlining_of_small_functions): Do not avoid
    diags for recursive inlining here.
    (cgraph_flatten): Adjust.
    (cgraph_decide_inlining_incrementally): Likewise.
    (estimate_function_body_sizes): Remove call cost handling.
    (compute_inline_parameters): Initialize caller edge call costs.
    * tree-inline.c (estimate_num_insns): Only account for call
    return value if it is used.
    (expand_call_inline): Avoid diagnostics on recursive inline
    functions here.
    * lto-cgraph.c (lto_output_edge): Output edge call costs.
    (input_edge): Input edge call costs.

    * gcc.dg/tree-ssa/inline-8.c: New testcase.

2011-02-22  Richard Guenther  <rguenther@suse.de>

    * ipa-inline.c (cgraph_estimate_edge_growth): New function.
    (cgraph_estimate_growth): Use it.
    (cgraph_edge_badness): Likewise.
    (cgraph_check_inline_limits): Take an edge argument.
    (cgraph_decide_inlining_of_small_functions): Adjust.
    (cgraph_decide_inlining): Likewise.

Added:
    branches/pretty-ipa/gcc/testsuite/ChangeLog.pretty-ipa
    branches/pretty-ipa/gcc/testsuite/gcc.dg/tree-ssa/inline-8.c
Modified:
    branches/pretty-ipa/gcc/ChangeLog.pretty-ipa
    branches/pretty-ipa/gcc/cgraph.c
    branches/pretty-ipa/gcc/cgraph.h
    branches/pretty-ipa/gcc/ipa-inline.c
    branches/pretty-ipa/gcc/lto-cgraph.c
    branches/pretty-ipa/gcc/tree-inline.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/47663] Very simple wrapper not inlined
  2011-02-09 15:52 [Bug middle-end/47663] New: Very simple wrapper not inlined rguenth at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-02-22 14:28 ` rguenth at gcc dot gnu.org
@ 2011-04-06  8:51 ` rguenth at gcc dot gnu.org
  2011-04-06 10:11 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-06  8:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47663

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-06 08:51:27 UTC ---
Author: rguenth
Date: Wed Apr  6 08:51:23 2011
New Revision: 172023

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172023
Log:
2011-04-06  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/47663
    * cgraph.h (struct cgraph_edge): Add call_stmt_size and
    call_stmt_time fields.
    (cgraph_edge_inlinable_p): Declare.
    (cgraph_edge_recursive_p): New inline function.
    * cgraph.c (cgraph_create_edge_1): Initialize call_stmt_size.
    (cgraph_clone_edge): Copy it.
    * ipa-inline.c (cgraph_estimate_edge_time): New function.
    Account for call stmt time.
    (cgraph_estimate_time_after_inlining): Take edge argument.
    (cgraph_estimate_edge_growth): Account call stmt size.
    (cgraph_estimate_size_after_inlining): Take edge argument.
    (cgraph_mark_inline_edge): Adjust.
    (cgraph_check_inline_limits): Likewise.
    (cgraph_recursive_inlining_p): Remove.
    (cgraph_edge_badness): Use cgraph_edge_recursive_p.
    (cgraph_decide_recursive_inlining): Take edge argument and
    adjust.
    (cgraph_decide_inlining_of_small_functions): Do not avoid
    diags for recursive inlining here.
    (cgraph_flatten): Adjust.
    (cgraph_decide_inlining_incrementally): Likewise.
    (estimate_function_body_sizes): Remove call cost handling.
    (compute_inline_parameters): Initialize caller edge call costs.
    (cgraph_estimate_edge_growth): New function.
    (cgraph_estimate_growth): Use it.
    (cgraph_edge_badness): Likewise.
    (cgraph_check_inline_limits): Take an edge argument.
    (cgraph_decide_inlining_of_small_functions): Adjust.
    (cgraph_decide_inlining): Likewise.
    * tree-inline.c (estimate_num_insns): Only account for call
    return value if it is used.
    (expand_call_inline): Avoid diagnostics on recursive inline
    functions here.
    * lto-cgraph.c (lto_output_edge): Output edge call costs.
    (input_edge): Input edge call costs.

    * gcc.dg/tree-ssa/inline-8.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/inline-8.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.c
    trunk/gcc/cgraph.h
    trunk/gcc/ipa-inline.c
    trunk/gcc/lto-cgraph.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/47663] Very simple wrapper not inlined
  2011-02-09 15:52 [Bug middle-end/47663] New: Very simple wrapper not inlined rguenth at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-04-06  8:51 ` rguenth at gcc dot gnu.org
@ 2011-04-06 10:11 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-06 10:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47663

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-06 10:11:34 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-06 10:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09 15:52 [Bug middle-end/47663] New: Very simple wrapper not inlined rguenth at gcc dot gnu.org
2011-02-09 16:20 ` [Bug middle-end/47663] " rguenth at gcc dot gnu.org
2011-02-10 13:08 ` rguenth at gcc dot gnu.org
2011-02-22 14:28 ` rguenth at gcc dot gnu.org
2011-04-06  8:51 ` rguenth at gcc dot gnu.org
2011-04-06 10:11 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).