https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100182
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 50649 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50649&action=edit gcc12-pr100182.patch Untested patch for this particular peephole2. But, 1) I'm not sure it is 100% safe even for spill slots 2) I don't know what to do with the remaining 7 peephole2s I'm afraid during peephole2 pass we don't have anything comparable to RTL DSE infrastructure, and unfortunately the last RTL DSE2 pass is 5 passes before peephole2. So matching these insn sequences e.g. could be done in some machine specific pass before RTL DSE2 instead of peephole2 and let RTL DSE2 optimize away what seems unnecessary, or use some patterns that RTL DSE2 would recognize on its own.