How to find out which optimizations are actually applied when using gcc?(使用gcc时如何找出实际应用了哪些优化?)
问题描述
使用 IBM 的 XL 编译器系列,可以提供两个选项(-qreport
和 -qlist
)来为每个源文件生成报告,其中包括有关哪些优化的信息应用,或者代码的哪些部分无法优化(以及为什么).
With IBM's XL compiler family it is possible to supply two options (-qreport
and -qlist
) to generate reports for each source file that include information on which optimizations were applied, or which parts of the code could not be optimized (and why).
是否有可能为 GNU 的 g++ 获得类似的报告 - 如果是,如何做?
Is it possible to get a similar reporting for GNU's g++ - and if yes, how to do it?
推荐答案
看看 -fdump-tree-[switch]
标志.您可以使用 -fdump-tree-all
获取大量信息.
Have a look at the -fdump-tree-[switch]
flags. You can use -fdump-tree-all
to get loads of information.
也在主干 gcc 中 -fopt-info-[options]
会给你访问更高级别的优化信息,例如当应用特定优化时,错过等,例如
Also in trunk gcc -fopt-info-[options]
will give you access higher level optimization information e.g. when particular optimizations were applied, missed etc e.g.
-fopt-info-inline-optimized-missed
打印所有成功和错过的内联优化(在本例中为 stderr
).这显然是相当新的功能,所以我不确定它的支持情况如何.
Prints all successful and missed inlining optimizations (to stderr
in this case). This is obviously pretty new functionality so I'm not sure how well supported it is yet.
在早期版本中,他们有 -ftree-vectorizer-verbose=n
现在已被弃用,取而代之的是 opt-info.
In earlier releases they had -ftree-vectorizer-verbose=n
which is now being deprecated in favor of opt-info.
此处列出了所有这些选项https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html 虽然挑选有用的可能有点棘手.
All these options are listed here https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html though it can be a bit tricky to pick out the useful ones.
这篇关于使用gcc时如何找出实际应用了哪些优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用gcc时如何找出实际应用了哪些优化?


基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07