public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* bug w/ inline of inline?
@ 2004-10-18  4:48 Eliot Dresselhaus
  2004-10-18  6:23 ` Zack Weinberg
  0 siblings, 1 reply; 5+ messages in thread
From: Eliot Dresselhaus @ 2004-10-18  4:48 UTC (permalink / raw)
  To: gcc


In this example

    static inline int f (int x) { return x + 1; }

    static inline int g (int x, inline int f (int x))
    { return 1 + f (x); }

    int h (int x)
    { return g (x, f); }

is h supposed to optimize to return x + 2 or supposed to actually call
f.  Here's what I get with current gcc mainline cvs -O2

    f:
	    leal	1(%rdi), %eax
	    ret

    h:
	    call	f
	    incl	%eax
	    ret

Is this a bug?  If not, how to I get gcc to emit "return x + 2"?

Thanks,

Eliot

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

* Re: bug w/ inline of inline?
  2004-10-18  4:48 bug w/ inline of inline? Eliot Dresselhaus
@ 2004-10-18  6:23 ` Zack Weinberg
  2004-10-18  7:40   ` Andrew Pinski
  0 siblings, 1 reply; 5+ messages in thread
From: Zack Weinberg @ 2004-10-18  6:23 UTC (permalink / raw)
  To: Eliot Dresselhaus; +Cc: gcc

Eliot Dresselhaus <edressel@cisco.com> writes:

> In this example
>
>     static inline int f (int x) { return x + 1; }
>
>     static inline int g (int x, inline int f (int x))
>     { return 1 + f (x); }
>
>     int h (int x)
>     { return g (x, f); }
>
> is h supposed to optimize to return x + 2 or supposed to actually call
> f.

GCC is allowed to do either.  It would be good if it produced 
"return x + 2;"  Please file a missed-optimization bug report.

Note that declaring the parameter inline is incorrect C.

zw

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

* Re: bug w/ inline of inline?
  2004-10-18  6:23 ` Zack Weinberg
@ 2004-10-18  7:40   ` Andrew Pinski
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Pinski @ 2004-10-18  7:40 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: gcc, Eliot Dresselhaus


On Oct 17, 2004, at 8:18 PM, Zack Weinberg wrote:

> Eliot Dresselhaus <edressel@cisco.com> writes:
>
>> In this example
>>
>>     static inline int f (int x) { return x + 1; }
>>
>>     static inline int g (int x, inline int f (int x))
>>     { return 1 + f (x); }
>>
>>     int h (int x)
>>     { return g (x, f); }
>>
>> is h supposed to optimize to return x + 2 or supposed to actually call
>> f.
>
> GCC is allowed to do either.  It would be good if it produced
> "return x + 2;"  Please file a missed-optimization bug report.

We have one already, PR 9079: <http://gcc.gnu.org/PR9079>.

Thanks,
Andrew Pinski
a gcc bug master

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

* Re: bug w/ inline of inline?
  2004-10-18  8:02 Richard Kenner
@ 2004-10-18 19:28 ` Richard Henderson
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2004-10-18 19:28 UTC (permalink / raw)
  To: Richard Kenner; +Cc: zack, gcc

On Sun, Oct 17, 2004 at 10:43:34PM -0400, Richard Kenner wrote:
> I saw this sort of thing a while ago when I was playing with similar
> artificial tests.  The reason the inlining isn't done is because of
> heuristics in cgraph.  It's looking at the number of times the function
> is used and such and the artificial cases don't tend to trigger the
> inlining.

Not even close.

The function isn't inlined because it's called indirectly, and we don't
re-do inlining after we cse the constant function address into the call.



r~

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

* Re: bug w/ inline of inline?
@ 2004-10-18  8:02 Richard Kenner
  2004-10-18 19:28 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Kenner @ 2004-10-18  8:02 UTC (permalink / raw)
  To: zack; +Cc: gcc

    GCC is allowed to do either.  It would be good if it produced 
    "return x + 2;"  Please file a missed-optimization bug report.

I saw this sort of thing a while ago when I was playing with similar
artificial tests.  The reason the inlining isn't done is because of
heuristics in cgraph.  It's looking at the number of times the function
is used and such and the artificial cases don't tend to trigger the
inlining.

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

end of thread, other threads:[~2004-10-18 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-18  4:48 bug w/ inline of inline? Eliot Dresselhaus
2004-10-18  6:23 ` Zack Weinberg
2004-10-18  7:40   ` Andrew Pinski
2004-10-18  8:02 Richard Kenner
2004-10-18 19:28 ` Richard Henderson

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).