diff options
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/combine.c | 32 |
2 files changed, 33 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c0249e8..c8e1690 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2017-11-17 Segher Boessenkool <segher@kernel.crashing.org> + * combine.c (added_notes_insn): New. + (try_combine): Handle added_notes_insn like added_links_insn. + Rewrite return value code. + (distribute_notes): Set added_notes_insn to the earliest insn we added + a note to. + +2017-11-17 Segher Boessenkool <segher@kernel.crashing.org> + PR rtl-optimization/82621 * combine.c (try_combine): Do not split PARALLELs of two SETs if the dest of one of those SETs is unused. diff --git a/gcc/combine.c b/gcc/combine.c index 404cf33..ab51543 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -302,6 +302,10 @@ static HARD_REG_SET newpat_used_regs; static rtx_insn *added_links_insn; +/* And similarly, for notes. */ + +static rtx_insn *added_notes_insn; + /* Basic block in which we are performing combines. */ static basic_block this_basic_block; static bool optimize_this_for_speed_p; @@ -2790,6 +2794,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, std::swap (i1, i2); added_links_insn = 0; + added_notes_insn = 0; /* First check for one important special case that the code below will not handle. Namely, the case where I1 is zero, I2 is a PARALLEL @@ -4752,12 +4757,13 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, combine_successes++; undo_commit (); - if (added_links_insn - && (newi2pat == 0 || DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (i2)) - && DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (i3)) - return added_links_insn; - else - return newi2pat ? i2 : i3; + rtx_insn *ret = newi2pat ? i2 : i3; + if (added_links_insn && DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (ret)) + ret = added_links_insn; + if (added_notes_insn && DF_INSN_LUID (added_notes_insn) < DF_INSN_LUID (ret)) + ret = added_notes_insn; + + return ret; } /* Get a marker for undoing to the current state. */ @@ -14628,10 +14634,22 @@ distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2, { XEXP (note, 1) = REG_NOTES (place); REG_NOTES (place) = note; + + /* Set added_notes_insn to the earliest insn we added a note to. */ + if (added_notes_insn == 0 + || DF_INSN_LUID (added_notes_insn) > DF_INSN_LUID (place)) + added_notes_insn = place; } if (place2) - add_shallow_copy_of_reg_note (place2, note); + { + add_shallow_copy_of_reg_note (place2, note); + + /* Set added_notes_insn to the earliest insn we added a note to. */ + if (added_notes_insn == 0 + || DF_INSN_LUID (added_notes_insn) > DF_INSN_LUID (place2)) + added_notes_insn = place2; + } } } |