https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70408
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|rtl-optimization |c
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note teaching this trick requires a huge amount of work as you need to teach
GCC more about order of operands does not matter; this requires work in the
front-end and then in the gimple level and then maybe the middle-end.
Is it worth it for the gain, most likely not, you are more likely just to get
better code by not depending on unspecified behavior in C.
># why lea instead of add rdi,2?
Because lea does not clobber the flags, so this might be faster, it depends on
the machine.
Also try -Os you might see a difference code.