问题描述
我知道 -O1 会自动打开某些标志.这些标志可以手动打开.如果我不指定 -O1,应该仍然可以通过指定 -O1 打开的所有标志来获得 -O1 优化.
I know that -O1 automatically turns on certain flags. These flags can be turned on manually though. If I don't specify -O1, it should still be possible to get -O1 optimization by specifying all the flags that -O1 turns on.
我试过了
-fthread-jumps -fcprop-registers -fguess-branch-probability
但它仍然不做 -O1 优化.我可以知道我何时使用 gprof,因为性能不太好.
but it still does not do -O1 optimization. I can tell when I use gprof because the performance is not as good.
我应该打开哪些标志来获得 -O1 优化?
Which flags do I turn on to get -O1 optimization?
推荐答案
一种方法:
gcc -O1 -c -Q -v dummy.c
(其中 dummy.c 是您的文件名.)这会导致 gcc 将用于命令行的标志喷出.
(where dummy.c is your filename.) This causes gcc to spew the flags used to the command line.
请参阅 kastauyra 对此的回答.看来您无法仅使用 -f
标志来模拟完整的 -O1
优化.
Please see kastauyra's answer on this. It appears you cannot simulate full -O1
optimization with -f
flags alone.
这篇关于如何在不指定 -O1 的情况下获得 gcc -O1 优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!