does #pragma GCC optimize work with gcc 4.9.2 LTO?

starlight.2014q4@binnacle.cx starlight.2014q4@binnacle.cx
Mon Nov 24 20:02:00 GMT 2014


Hello,

Starting to use -flto and have a question.

Have a medium-size program where
the majority of the code runs best
with -O2.  However a handful of
functions run _much_ better with -O3.

In the non-LTO approach this is a simple
matter of compiling each module with
the appropriate optimization flag.

With LTO, it appears the link-time
optimizer works at only one level,
either the explicitly chosen one or
the level found in the first .o

Can we use

#pragma GCC push_options
#pragma GCC optimize ("-O3")
   function() {}
#pragma GCC pop_options

To obtain the desired mixed-optimization
with -flto?

Is ok if the outcome is not perfectly
the same.  In our case the specific
optimization that matter are loop
unrolling, inlining of small functions,
and bit field access optimization.

Working with gcc/g++ 4.9.2 and binutils 2.24.

Thanks



More information about the Gcc-help mailing list