[Bug c++/77543] ARM: G++ generates redundant instructions at -O0

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 9 21:09:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77543

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is not a bug which we are going to fix.
The reason why C++ is different is due to the getNum() needs to be wrapped with
a tree which allows for eh to be correct.  GCC likes to wrap "complex"
statement but does not go and remove the wrapping when it can be proved it is
no longer needed.
If there was a temp associated with getNum you would need a cleanup statements
which is why the wrapping happens in the first place.

Basically GCC project has mentioned -O0 code generation is not always the best,
C++ is even worse.

By the way you get the same code between the two front-ends if you used a
variable for the return of getNum().


More information about the Gcc-bugs mailing list