GCC标准的优化行为 [英] GCC standard optimizations behavior

查看:217
本文介绍了GCC标准的优化行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面我编译-O2优化级别(用gcc 4.8.4)的输入程序和测量执行时间:

Here I compile an input program with -O2 optimization level (with gcc 4.8.4) and measure the execution time:

gcc -O2 -c test.c -o obj.o
TIMEFORMAT='%3R' &&  time(./obj.o)
execution time = 1.825

当我更换-O2标志与已打开,在GCC曼努埃尔在级别-O2的https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Optimize-Options.html#Optimize-Options这样的:

gcc -fauto-inc-dec -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdse -fguess-branch-probability -fif-conversion2 -fif-conversion -fipa-pure-const -fipa-profile -fipa-reference -fmerge-constants -fsplit-wide-types -ftree-bit-ccp  -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-slsr -ftree-sra -ftree-pta -ftree-ter -funit-at-a-time -fthread-jumps -falign-functions  -falign-jumps -falign-loops  -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps  -fcse-skip-blocks -fdelete-null-pointer-checks -fdevirtualize -fexpensive-optimizations -fgcse  -fgcse-lm  -fhoist-adjacent-loads -finline-small-functions -findirect-inlining -fipa-sra -foptimize-sibling-calls -fpartial-inlining -fpeephole2 -fregmove  -freorder-blocks  -freorder-functions -frerun-cse-after-loop -fsched-interblock  -fsched-spec -fschedule-insns  -fschedule-insns2 -fstrict-aliasing -fstrict-overflow -ftree-switch-conversion -ftree-tail-merge -ftree-pre -ftree-vrp -c test.c -o obj.o
    TIMEFORMAT='%3R' &&  time(./obj.o)
execution time = 2.652

我的问题是,为什么执行时间是不同的,即便如此,我应用了同样的优化?

My question is why the execution time is different even so, I applied the same optimizations ?

更新

如果(根据GCC文档):

if (according to GCC documentation):

不是所有的优化是通过一个标志直接控制。

Not all optimizations are controlled directly by a flag.

因此​​,研究人员如何利用重现优化序列的速度甚至超过标准的优化序列(使用进化算法,他们
用于生成数以千计的优化序列,并收集那些
在执行时间期限

So how can researchers use to reproduce optimization sequences even faster than standard optimization sequences (using evolutionary algorithms they use to generate thousands of optimization sequences and gather those with highest impact in term of execution time)

作为一个例子Acovea http://hg.ahs3.net/ acovea /于Debian / HTML / acoveaga.html

as an example "Acovea" http://hg.ahs3.net/acovea/debian/html/acoveaga.html

和科尔 http://users.elis.ugent.be /~leeckhou/papers/cgo08.pdf

推荐答案

有2好的优化应该知道的:

There is 2 good optimization that should be know:


  • -O2:优化空间和时间(注意:不初始化变量)

  • -Os:优化空格和时间(注意:不能初始化变量)

  • -O2: Optimize space and time (caution: does not initialize variable)
  • -Os: Optimize space and time (caution: does not initialize variable)

这篇关于GCC标准的优化行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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