Re: how about performance of the program compiled by -O2 other than -Os?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Dessent <brian@xxxxxxxxxxx> writes:

> 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.

This is correct.  I'll just add that -Os is the same as -O2, except
that when there is a tradeoff between space and time -Os prefers space
and -O2 prefers time.  As these are heuristic tradeoffs, it is
entirely possible that -Os will generate faster code in some cases.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux