https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81611
--- Comment #6 from Alexandre Oliva <aoliva at gcc dot gnu.org> --- Created attachment 42969 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42969&action=edit complementary candidate patch This patch complements the earlier one. On AVR, unlike other ports, we had the increment computed into a separate pseudo, then the memory store using the original pseudo, then the copy of the separate pseudo to the original one. auto_inc_dec can't deal with such a sequence. It could deal with it if the increment was after the memory access, which would have already eliminated the temporary and the copy. So, instead of extending auto_inc_dec to deal with a more complex scenario involving 3 insns, I decided to try and move the increment down, past the memory access, so as to benefit even ports without auto_inc addressing modes by avoiding SSA conflicts and reducing the use of temporaries. It moves IV increment stmts that are not used within their own blocks closer to the end of the block, so as to reduce the likelihood of a SSA conflict with the PHI node. This also makes it more likely that the increment will appear after memory uses with which it can be combined into a post_inc addressing mode.