https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93996
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This seems to fix the issue (but I am not a scheduler expert and I am not 100%
sure about it):
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 1d3de7b6a76..9ca986eabdd 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -4239,6 +4239,8 @@ remove_notes (rtx_insn *head, rtx_insn *tail)
if (insn != tail)
{
remove_insn (insn);
+ if (NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_BASIC_BLOCK)
+ next = NEXT_INSN (next);
add_reg_note (next, REG_SAVE_NOTE,
GEN_INT (NOTE_INSN_EPILOGUE_BEG));
break;