https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90217
Bug ID: 90217 Summary: Greater optimization of C++ Code Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: stevexiong98 at hotmail dot com Target Milestone: --- Hi, This is not so much a bug, but more of an enhancement. There are 2 pieces of code I have listed below which should translate to identical assembly instructions at high levels of compiler optimization (level 3) but currently do not. https://godbolt.org/z/Zn7FMK https://godbolt.org/z/wB8eZd Using ARM GCC 8.2, the code in the second link involves the stack pointer and extra load/store operations to the newly-created stack space. There are more assembly instructions in link 2's code than in link 1's code. However, in Godbolt if you switch the compiler to Clang, at optimization 3 both pieces of code manage to compile down to the same minimal Assembly instructions. Switching the compiler to x86-64 GCC (trunk), the code in the second link also has a few extra operations compared the first link's code. Is it possible to set ARM GCC and x86-64 GCC to a particular optimization setting that allows both links' code to have matching assembly instructions? If not, is it possible that in a future release, both compilers could apply enough optimizations so that the assembly in link 1 matches link 2? Thanks