From: Bernd Schmidt Date: Mon, 7 Nov 2016 17:03:55 +0000 (+0000) Subject: emit-rtl.c (emit_copy_of_insn_after): Duplicate notes in order. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1581a12c3577a2d9048d47b0b7205df772c308db;p=gcc.git emit-rtl.c (emit_copy_of_insn_after): Duplicate notes in order. * emit-rtl.c (emit_copy_of_insn_after): Duplicate notes in order. * sel-sched-ir.c (create_copy_of_insn_rtx): Likewise. * rtl.h (duplicate_reg_notes): Declare. * rtlanal.c (duplicate_reg_note): New function. From-SVN: r241913 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d1cbb719f9..331540092d1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-11-07 Bernd Schmidt + * emit-rtl.c (emit_copy_of_insn_after): Duplicate notes in order. + * sel-sched-ir.c (create_copy_of_insn_rtx): Likewise. + * rtl.h (duplicate_reg_notes): Declare. + * rtlanal.c (duplicate_reg_note): New function. + PR rtl-optimization/77309 * combine.c (make_compound_operation): Allow EQ for IN_CODE, and don't assume an equality comparison for plain COMPARE. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index e27587b6699..9ea0c8fb888 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -6168,17 +6168,19 @@ emit_copy_of_insn_after (rtx_insn *insn, rtx_insn *after) which may be duplicated by the basic block reordering code. */ RTX_FRAME_RELATED_P (new_rtx) = RTX_FRAME_RELATED_P (insn); + /* Locate the end of existing REG_NOTES in NEW_RTX. */ + rtx *ptail = ®_NOTES (new_rtx); + while (*ptail != NULL_RTX) + ptail = &XEXP (*ptail, 1); + /* Copy all REG_NOTES except REG_LABEL_OPERAND since mark_jump_label will make them. REG_LABEL_TARGETs are created there too, but are supposed to be sticky, so we copy them. */ for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) if (REG_NOTE_KIND (link) != REG_LABEL_OPERAND) { - if (GET_CODE (link) == EXPR_LIST) - add_reg_note (new_rtx, REG_NOTE_KIND (link), - copy_insn_1 (XEXP (link, 0))); - else - add_shallow_copy_of_reg_note (new_rtx, link); + *ptail = duplicate_reg_note (link); + ptail = &XEXP (*ptail, 1); } INSN_CODE (new_rtx) = INSN_CODE (insn); diff --git a/gcc/rtl.h b/gcc/rtl.h index 3bb6a224c09..7a44e3bd3ef 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3019,6 +3019,7 @@ extern rtx alloc_reg_note (enum reg_note, rtx, rtx); extern void add_reg_note (rtx, enum reg_note, rtx); extern void add_int_reg_note (rtx, enum reg_note, int); extern void add_shallow_copy_of_reg_note (rtx_insn *, rtx); +extern rtx duplicate_reg_note (rtx); extern void remove_note (rtx_insn *, const_rtx); extern void remove_reg_equal_equiv_notes (rtx_insn *); extern void remove_reg_equal_equiv_notes_for_regno (unsigned int); diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index c98a7086981..4d7aad0dff0 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -2304,6 +2304,20 @@ add_shallow_copy_of_reg_note (rtx_insn *insn, rtx note) add_reg_note (insn, REG_NOTE_KIND (note), XEXP (note, 0)); } +/* Duplicate NOTE and return the copy. */ +rtx +duplicate_reg_note (rtx note) +{ + reg_note kind = REG_NOTE_KIND (note); + + if (GET_CODE (note) == INT_LIST) + return gen_rtx_INT_LIST ((machine_mode) kind, XINT (note, 0), NULL_RTX); + else if (GET_CODE (note) == EXPR_LIST) + return alloc_reg_note (kind, copy_insn_1 (XEXP (note, 0)), NULL_RTX); + else + return alloc_reg_note (kind, XEXP (note, 0), NULL_RTX); +} + /* Remove register note NOTE from the REG_NOTES of INSN. */ void diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c index 26bc1422167..02157b4c736 100644 --- a/gcc/sel-sched-ir.c +++ b/gcc/sel-sched-ir.c @@ -5762,6 +5762,11 @@ create_copy_of_insn_rtx (rtx insn_rtx) res = create_insn_rtx_from_pattern (copy_rtx (PATTERN (insn_rtx)), NULL_RTX); + /* Locate the end of existing REG_NOTES in NEW_RTX. */ + rtx *ptail = ®_NOTES (res); + while (*ptail != NULL_RTX) + ptail = &XEXP (*ptail, 1); + /* Copy all REG_NOTES except REG_EQUAL/REG_EQUIV and REG_LABEL_OPERAND since mark_jump_label will make them. REG_LABEL_TARGETs are created there too, but are supposed to be sticky, so we copy them. */ @@ -5770,11 +5775,8 @@ create_copy_of_insn_rtx (rtx insn_rtx) && REG_NOTE_KIND (link) != REG_EQUAL && REG_NOTE_KIND (link) != REG_EQUIV) { - if (GET_CODE (link) == EXPR_LIST) - add_reg_note (res, REG_NOTE_KIND (link), - copy_insn_1 (XEXP (link, 0))); - else - add_reg_note (res, REG_NOTE_KIND (link), XEXP (link, 0)); + *ptail = duplicate_reg_note (link); + ptail = &XEXP (*ptail, 1); } return res;