如何找出使用 gcc 时实际应用了哪些优化? [英] How to find out which optimizations are actually applied when using gcc?

查看:33
本文介绍了如何找出使用 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.

同样在trunk 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 时实际应用了哪些优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆