function order optimization

alex margolin
Sat Aug 3 11:44:00 GMT 2013

Did you mean "-fprofile-use=path" ? I read about it and it seems it
triggers other optimizations (loop unrolling, branch prediction) but
not the function order. Is this true, or does it optimize function
order as well?

Below is its excerpt from the manual:

Enable profile feedback directed optimizations, and optimizations generally
profitable only with profile feedback available.
The following options are enabled: -fbranch-probabilities, -fvpt,
-funroll-loops, -fpeel-loops, -ftracer, -ftree-vectorize,
By default, GCC emits an error message if the feedback profiles do not
match the source code. This error can be turned into a warning by using
‘-Wcoverage-mismatch’. Note this may result in poorly optimized code.
If path is specified, GCC looks at the path to find the profile feedback data
files. See ‘-fprofile-dir’.
The following options control compiler behavior regarding
floating-point arithmetic.
These options trade off between speed and correctness. All must be
specifically enabled.

On Sat, Aug 3, 2013 at 2:18 PM, Ángel González <> wrote:
> On 03/08/13 12:47, alex margolin wrote:
>> (...)
>> The way this works is that you build icc with profiling, run it to
>> gather the profiling data, and then build again based on this data.
>> The optimized build reorganizes the functions to be roughly in the
>> order they are called in the code, which makes most critical functions
>> be on the same page as their callers, and a few pages keep all the
>> performance critical code.
>> Is there a way to do the same (or similar) with gcc?
>> I'm ready to do some coding for gcc (plugin?) if it's feasible...
>> Thanks,
>> Alex
> Yes, search for 'profile' in the gcc manual.

More information about the Gcc-help mailing list