https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81556
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 41832 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41832&action=edit gcc8-pr81556.patch Untested fix. The current code whether a SSA_NAME can be reused or not is based on whether all the rhs2 ops are the same from the toplevel stmt (and whether there is powi/negate). That should work fine as long as the number of ops is the same after optimization, but in this case there is a removal of reduncant op, at which point that doesn't work anymore.