Optimization, inline functions

Diego Novillo dnovillo@google.com
Fri Jul 4 12:38:00 GMT 2008


On Fri, Jul 4, 2008 at 02:14, me22 <me22.ca@gmail.com> wrote:
> On Fri, Jul 4, 2008 at 01:34, Lee, Newbie <utmw0@hanmail.net> wrote:
>> 0. Does 'gcc -O2' make functions inline?

Yes, but uses a slightly more conservative cost model than O3.  It
mostly inlines functions that are smaller than the call overhead.

>> 1. Is function inlining is dangerous?
>>

No.  But if you are trying to preserver code size, it's better to avoid it.

>> 2. Is 'gcc -O3 ' safe? (I heard -O2 is recommended)
>>
>
> Depends on the code.  -O3 contains things such as strict aliasing
> which is one part of the standard that much code doesn't follow.

No.  Strict aliasing is on by default at -O2 and -O3.


Diego.



More information about the Gcc-help mailing list