Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jan 1999 17:29:57 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        peter.jeremy@auss2.alcatel.com.au, current@FreeBSD.ORG
Subject:   Re: indent(1) and style(9) (was: btokup() macro in sys/malloc.h)
Message-ID:  <199901290129.RAA16381@apollo.backplane.com>
References:   <199901290122.RAA27878@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
:> 
:>     More then judicious use -- inlines are an incredible advantage.  Most
:>     people don't realize that GCC will optimize constant arguments through
:>     an inline call.  Try this:
:> 
:> static __inline

    Yah, and if it's static it will not even output code for fubar.

    I've never trusted -O3, though, and you can't put static procedures
    in header files ( because then you can't fall back to -O2 ).  Thus,
    for this sort of optimization to work the procedure must be in the same
    source file, which kills the modularity.  Also, on top of all of that,
    GCC may not make a good decision on whether to actually inline the
    static or whether to call it - it might wind up inlining a large
    routine that you call many times in your module and both bloat the code
    and destroy the L1 cache.

    I think it's better to make things explicitly __inline and to put them in
    the proper subsystem's header files.  It isn't worth depending on -O3
    for things to compile:

       -O3    Optimize  yet  more.  This  turns on everything -O2
              does, along with  also  turning  on  -finline-func-
              tions.

						-Matt

:Matt,
:
:int
:fubar(int c)
:{
:    if (c & 1)
:        ++c;
:     if (c & 2)
:         ++c;
:     return(c);
:}
:
:void
:fubar2(void)
:{
:    volatile int x;
:
:     x = fubar(0);
:     x = fubar(1);
:     x = fubar(2);
:     x = fubar(3);
:}
: 
:% cc -S -O3 x.c
:% cat x.s
:
:fubar2:
:        pushl %ebp
:        movl %esp,%ebp
:        subl $4,%esp
:        xorl %eax,%eax		<----- fubar (0)
:        movl %eax,-4(%ebp)
:        movl $3,-4(%ebp)	<----- fubar (1)
:        movl $3,-4(%ebp)	<----- fubar (2)
:        movl $4,-4(%ebp)	<----- fubar (3)
:        leave
:        ret
:
:-- 
:Steve
:
:finger kargl@troutmask.apl.washington.edu
:http://troutmask.apl.washington.edu/~clesceri/kargl.html
:

					Matthew Dillon 
					<dillon@backplane.com>

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901290129.RAA16381>