开发者

Getting an optimization report from GCC

I would like to know if there is an option I can use with GCC to get a detailed report on the optimization actually chosen and performed by the compiler. This is possible with the Intel C compiler using the -opt-report. I do not want to look at the assembly file and figure out the optimization. I am specifically looking for the loop unrolling and loop tiling f开发者_高级运维actors chosen by the compiler.


Although it's not a report in the sense of aggregated information, you might try the -fdump-ipa-all option which makes gcc produce dump files which at least keep you from having to analyse assembler code on what happened.

Regarding loop optimization the -fdump-rtl-loop2 option might be of interest.

For details on all this please see the section Options for Debugging Your Program or GCC of the manual.


The reports from GCC is not that straight forward as like intel, but we can prefer. here is the detailed options use for optimization done by GCC.

-fopt-info -fopt-info-options -fopt-info-options=filename Controls optimization dumps from various optimization passes. If the ‘-options’ form is used, options is a list of ‘-’ separated option keywords to select the dump details and optimizations.

The options can be divided into three groups:

options describing what kinds of messages should be emitted, options describing the verbosity of the dump, and options describing which optimizations should be included. The options from each group can be freely mixed as they are non-overlapping. However, in case of any conflicts, the later options override the earlier options on the command line.

The following options control which kinds of messages should be emitted:

‘optimized’ Print information when an optimization is successfully applied. It is up to a pass to decide which information is relevant. For example, the vectorizer passes print the source location of loops which are successfully vectorized.

‘missed’ Print information about missed optimizations. Individual passes control which information to include in the output.

‘note’ Print verbose information about optimizations, such as certain transformations, more detailed messages about decisions etc.

‘all’ Print detailed optimization information. This includes ‘optimized’, ‘missed’, and ‘note’.

The following option controls the dump verbosity:

‘internals’ By default, only “high-level” messages are emitted. This option enables additional, more detailed, messages, which are likely to only be of interest to GCC developers.

One or more of the following option keywords can be used to describe a group of optimizations:

‘ipa’ Enable dumps from all interprocedural optimizations.

‘loop’ Enable dumps from all loop optimizations.

‘inline’ Enable dumps from all inlining optimizations.

‘omp’ Enable dumps from all OMP (Offloading and Multi Processing) optimizations.

‘vec’ Enable dumps from all vectorization optimizations.

‘optall’ Enable dumps from all optimizations. This is a superset of the optimization groups listed above.

If options is omitted, it defaults to ‘optimized-optall’, which means to dump messages about successful optimizations from all the passes, omitting messages that are treated as “internals”.

If the filename is provided, then the dumps from all the applicable optimizations are concatenated into the filename. Otherwise the dump is output onto stderr. Though multiple -fopt-info options are accepted, only one of them can include a filename. If other filenames are provided then all but the first such option are ignored.

Note that the output filename is overwritten in case of multiple translation units. If a combined output from multiple translation units is desired, stderr should be used instead.

In the following example, the optimization info is output to stderr:

gcc -O3 -fopt-info This example:

gcc -O3 -fopt-info-missed=missed.all outputs missed optimization report from all the passes into missed.all, and this one:

gcc -O2 -ftree-vectorize -fopt-info-vec-missed prints information about missed optimization opportunities from vectorization passes on stderr. Note that -fopt-info-vec-missed is equivalent to -fopt-info-missed-vec. The order of the optimization group names and message types listed after -fopt-info does not matter.

As another example,

gcc -O3 -fopt-info-inline-optimized-missed=inline.txt outputs information about missed optimizations as well as optimized locations from all the inlining passes into inline.txt.

Finally, consider:

gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt Here the two output filenames vec.miss and loop.opt are in conflict since only one output file is allowed. In this case, only the first option takes effect and the subsequent options are ignored. Thus only vec.miss is produced which contains dumps from the vectorizer about missed opportunities.


You may also consider fsave-optimization-record option

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜