I tried to optimize C code with gcc. If I use -O1 option will have a better running time but if i use equivalent
-fauto-inc-dec
-fcompare-elim
-fcprop-registers
-fdce
-fdefer-pop
-fdelayed-branch
-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
its like I didn't use any options flag. GCC version is 4.8.2. Please, who can explain me why? I just found that order of these flags matter but I didn't found which order is in -O1.
According to the documentation,
Most optimizations are only enabled if an -O level is set on the command line. Otherwise they are disabled, even if individual optimization flags are specified.
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html (emphasis mine)
When it continues to list the specific flags you can set, it notes:
You can use the following flags in the rare cases when “fine-tuning” of optimizations to be performed is desired.
Which makes it pretty clear that they don't expect you to make an entirely custom set of optimisation options, but rather choose the general level which best fits your scenario (which will vary depending on whether you are currently debugging, shipping, etc.), then fine-tune any flags which your code benefits from having on or off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With