This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: function order optimization
- From: Ãngel GonzÃlez <keisial at gmail dot com>
- To: alex margolin <margolin dot alex at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Sat, 03 Aug 2013 14:15:09 +0200
- Subject: Re: function order optimization
- References: <CAO8Ct5t2B6KPgCyzfRpCCMukAmH=OxdZBm=mV0dH-58i4mRNYQ at mail dot gmail dot com> <51FCE717 dot 1090802 at gmail dot com> <CAO8Ct5uLfVTg2PYme=uJCGWNako9_tNKa=fF0vYB6GwBqwXanQ at mail dot gmail dot com>
Please keep the mailing list in CC.
On 03/08/13 13:42, alex margolin wrote:
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,
ftree-loop-distribute-patterns
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.
Take a look at -freorder-functions:
'-freorder-functions'
Reorder functions in the object file in order to improve code
locality. This is implemented by using special subsections
'.text.hot' for most frequently executed functions and
'.text.unlikely' for unlikely executed functions. Reordering is
done by the linker so object file format must support named
sections and linker must place them in a reasonable way.
Also profile feedback must be available to make this option
effective. See '-fprofile-arcs' for details.
Enabled at levels '-O2', '-O3', '-Os'.
There are many profile-related options, and I know little of them, that's
why I directed you to the manual instead of trying to provide a recipe.
But you should be able to improve the results with them.