https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84327
Bug ID: 84327 Summary: Copy pasting the documented optimize flags is not equal to -O1 Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xyzdr4gon333 at googlemail dot com Target Milestone: --- Created attachment 43392 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43392&action=edit Program showing that the single optimization flags don't work as well as O1 My program reduces its runtime from 20s to 5s when using -O1. So I wanted to know which optimization is responsible for that and used the optimizations flags found here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html But not even when copy-pasting ALL flags up to -O3 listed there, can I reproduce the speedup to 5s! See the attached file which also contains code comments on how I did compile it. This seems to be a very long-standing bug (5+ years): https://stackoverflow.com/questions/12769173/selecting-gcc-optimisation-flags-equivalent-to-o1 https://stackoverflow.com/questions/20246357/gcc-using-o1-and-spelling-the-o1-options-out-leads-to-different-result-one-w And even after trying to find the difference by using -Q --help=optimizers which showed this diff: 17d16 < -fdelayed-branch 100a100 > -ftree-builtin-call-dce Even when adding -ftree-builtin-call-dce I still don't get the same speedup ?!?! In fact nothing changes... g++ "${O1Flags[@]}" -ftree-builtin-call-dce -std=c++11 optimizeFlags.cpp && ./a.out Tested with: g++ (Debian 7.3.0-3) 7.3.0 g++-8 (Debian 8-20180207-2) 8.0.1 20180207 (experimental) [trunk revision 257435]