GCC 3 inlining problem (no warning, too)

Wirawan Purwanto wirawan@camelot.physics.wm.edu
Mon Apr 8 11:04:00 GMT 2002


Hi,

Why does GCC 3 sometimes refuse to inline a simple function? Here I give
you a testcase to prove that point. Please extract the package and try to
compile them to see it yourself. I included the intermediate file
(.ii and .s) produced by various compilers (see below). Note that those
without ".mgw" in the name are compiled using cygwin. Files suffixed with
.v is the stderr output given by invoking "gcc -v (other options)".

Take a look at the assembly codes. In all three cases, the subroutine
fastzero is correctly inlined. But embarassingly FastZero is not inlined
by GCC3. And if you try compiling this with -Winline, no warning will be
given that FastZero is not inlined.


THE COMPILER

Here are the compilers I used to test the problem. All are done in Win2K
environment:

gcc 2.95.3-5: from cygwin recent (stable) distribution (prebuilt binary)
gcc 2.95.3-6: from mingw 1.1 package (prebuilt binary)
gcc 3.0.3   : I compiled this myself with Win2K + cygwin

The compilation from gcc 2.95.x is in principle identical both cygwin
and mingw version. But gcc 3.0.3 does NOT inline the function FastZero
as the others do. Why does this happen? I noticed in the output assembly
of another program (much more complex than this, but I think it's
sufficient to look at this simple testcase) that many subroutines are NOT
inlined while they ARE if compiled under 2.95.x.


INVOCATION

To reproduce the program, compile the program using the following:

$GXX gcc-3.0.3-inline-problem.cpp -O3 -save-temps -v

where $GXX is the name of the appropriate g++ program.


PS:

Please bear with (slightly) complicated testcase. FastZero is basically
the same as fastzero, except that you can manually enable or disable fast
"memset" operation for certain types. By default, FastZero does not use
memset for user-defined types, except if you explicitly allow it, e.g. for
complex (a + i*b) classes.

Wirawan
<wirawan0@hotmail.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-3.0.3-inline-problem.tgz
Type: application/x-compressed
Size: 10459 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20020408/8376fec0/attachment.bin>


More information about the Gcc-bugs mailing list