From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Received: (qmail 17997 invoked from network); 9 Jan 2003 21:50:14 -0000 Received: from unknown (HELO Angel.zoy.org) (12.236.72.21) by 209.249.29.67 with SMTP; 9 Jan 2003 21:50:14 -0000 Received: by Angel.zoy.org (Postfix, from userid 1000) id 03FE2B76F; Thu, 9 Jan 2003 13:50:02 -0800 (PST) Date: Thu, 09 Jan 2003 22:52:00 -0000 From: Michel LESPINASSE To: Andrew Haley Cc: Carlo Wood , gcc@gcc.gnu.org Subject: Re: issues with inlining Message-ID: <20030109215002.GC31311@zoy.org> References: <20021219012212.GA26426@alinoe.com> <20030109193921.GB31311@zoy.org> <15901.53649.958282.305060@cuddles.cambridge.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15901.53649.958282.305060@cuddles.cambridge.redhat.com> User-Agent: Mutt/1.4i X-SW-Source: 2003-01/txt/msg00520.txt.bz2 On Thu, Jan 09, 2003 at 07:46:25PM +0000, Andrew Haley wrote: >>> 2) g++ 3.2.1 seems to totally ignore the inline keyword >>> and do as it pleases when being used with -O3. >>> Unfortunately, I know better than the compiler what >>> should be inlined - so, ignoring the inline keyword >>> and inlining other functions results in much slower >>> code. > > According to the docs > > `-O3' turns on all optimizations specified by `-O2' and also > turns on the `inline-functions' option. > > so why are you using -O3 if you want to control inlining by means of > the "inline" kwyword? there are two issues here: * compiler using inlining when we don't specify the inline keyword: you're totally right here, this is what -O3 does and we have no right to complain about it * compiler *not* using inlining even though we use the inline keyword: I think this is an issue. You can work around it by using always_inline but it's not backwards compatible with other gcc versions and it's nontrivial to write an autoconf test for it. >>> 4) The instruction limit that can be set with -finline-limit >>> seems to count instructions before optimization... > > True -- the inliner works at the source level before optimization is > performed. This is the best way to do it. You're most probably right on average. But you sometimes see code that use compile-time constants for specialization, i.e. one big inline routine that evaluates to something small based on the value of some constant parameters. In this case, the fact the inliner only sees the huge initial routine instead of the smaller one after specialization, combined with the fact the programmer can not use the inline keyword to force inlining, is an issue. Cheers, -- Michel "Walken" LESPINASSE Is this the best that god can do ? Then I'm not impressed.