Standard GCC Optimization

Here I compile an input program with an optimization level of -O2 (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 

and when I replace the -O2 flag with a list of options that are included, as defined by the GCC manuel at the -O2 level https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Optimize-Options.html#Optimize -Options like this:

 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 runtime is different, however, did I apply the same optimizations?

UPDATE

if (as per GCC documentation):

Not all optimizations are directly controlled by the flag.

So, how can researchers use to reproduce optimization sequences even faster than standard optimization sequences (using evolutionary algorithms that they use to generate thousands of optimization sequences and collect these with the highest impact on runtime)

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

and "Cole" http://users.elis.ugent.be/~leeckhou/papers/cgo08.pdf

+7
performance c compiler-optimization gcc execution-time
source share
1 answer

There are 2 good optimizations that should be known:

  • -O2: optimize space and time (caution: do not initialize the variable)
  • -O: Optimize space and time (caution: do not initialize the variable)
-3
source share

All Articles