-finline-functions tuning

Kurt Garloff kurt@garloff.de
Thu Aug 30 04:10:00 GMT 2001


Hi,

some people reported worse performance with -O3 as compared to -O2.
It seems that -finline-functions causes too many functions to be
inlined sometimes. This seems to be true especially in cases, where 
the authors of the code have used the inline keyword with some care.

This is especially bad for C++, where the inliner has some limits to
prevent excessive recursive inlining, so we may end up inlining comparably
large functions (which are not declared inline, but considered because they
fit below the inlining limit with -finline-functions) and then not inlining
functions which were declared inline, because we already inlined too much.

One possible solution is to still give functions declared inline a bonus
over the ones only inlined because of the compiler flag. Or use a lower
limit for the latter, which is the same.
This is what the RTL inlliner does anyway, so we also want to do it for the
C++ tree inliner as well. Unfortunately, for this, we need a new flag for the
functions, as we have to take a decision about this maybe multiple times
depending on the situation (previously inlined statements.)
[Note that the RTL inliner only had to take the decision once and then just
 set the inline flag; this was OK, as the decision did not consider
 auxiliary information only had to be taken 
 once, as no changing such as already inlined code.]
For the -finline-functions inlined functions, we just take half the limit of
the one for inline declared fns.

In my C++ benchmarks, the patch did prevent worse performance with -O3 (as
compared to -O2) in one case and in one it did not.
I'd like to hear your results.

Patch, which should be applied on top of v3 of my inliner patch against
3.0.1, is attached. It's also available via
http://www.garloff.de/kurt/freesoft/gcc/

Regards,
-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7jh8gxmLh6hyYd04RArNCAJ40oNbeS+ngDyGCXqW46OVyOo5xjACg2LHz
eUs28ua+HMBvGFMwuUpi+Q0=
=HNw2
-----END PGP SIGNATURE-----


More information about the Gcc mailing list