This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: how about performance of the program compiled by -O2 other than -Os?
- From: Brian Dessent <brian at dessent dot net>
- To: PRC <panruochen at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Fri, 13 Jun 2008 02:37:35 -0700
- Subject: Re: how about performance of the program compiled by -O2 other than -Os?
- References: <200806131704175321711@gmail.com>
- Reply-to: gcc-help <gcc-help at gcc dot gnu dot org>
PRC wrote:
> How about performance of the program compiled by -O2 other than -Os?
> I think -O2 will be better than -Os? But I am not sure how better.
It's impossible to answer such a vague question, as it depends on the
target architecture, the version of gcc, and most significantly the
nature of the code. You can only answer these kinds of questions with a
testcase, but I would not rule out -Os being faster in some
circumstances and on some architectures due to more code fitting in the
cache or better locality.
> BTW, how about -Os vs -O0?
-O0 means perform no optimization at all and I don't see how it's
meaningful to compare optimized to unoptimized code in either size or
speed. -O0 is useful when you want short compile times or you need to
be able to debug the resulting code easily, but other than that don't
expect much. But again, it entirely depends on the details and it's
really hard to conclude anything without a testcase.
Brian