From e8c8470b1cfdb6d9abebf7e976317abeb8956c40 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sat, 21 Apr 2001 18:45:00 +0000 Subject: [PATCH] flow.c (proagate_one_insn): Remove useless assignment. * flow.c (proagate_one_insn): Remove useless assignment. * jump.c (delete_insn): Tidy. * loop.c (try_copy_prop): When deleting an instruction with a REG_RETVAL note, delete the entire libcall sequence. (loop_delete_insns): New function. * unroll.c (initial_reg_note_copy): Copy INSN_LIST notes, even if we're not substituting into them yet. From-SVN: r41486 --- gcc/ChangeLog | 10 +++++ gcc/flow.c | 5 +-- gcc/jump.c | 7 ++- gcc/loop.c | 45 ++++++++++++++++--- .../gcc.c-torture/compile/20010421-1.c | 8 ++++ gcc/unroll.c | 2 +- 6 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20010421-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 45493ea341c..f829983bde0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2001-04-21 Mark Mitchell + + * flow.c (proagate_one_insn): Remove useless assignment. + * jump.c (delete_insn): Tidy. + * loop.c (try_copy_prop): When deleting an instruction with a + REG_RETVAL note, delete the entire libcall sequence. + (loop_delete_insns): New function. + * unroll.c (initial_reg_note_copy): Copy INSN_LIST notes, even if + we're not substituting into them yet. + 2001-04-21 Kazu Hirata * config/h8300/h8300.c (general_operand_src): Fix a comment typo. diff --git a/gcc/flow.c b/gcc/flow.c index 68b3aca02e9..a4b334d8e41 100644 --- a/gcc/flow.c +++ b/gcc/flow.c @@ -3734,10 +3734,7 @@ propagate_one_insn (pbi, insn) pbi->cc0_live = 0; if (libcall_is_dead) - { - prev = propagate_block_delete_libcall (pbi->bb, insn, note); - insn = NEXT_INSN (prev); - } + prev = propagate_block_delete_libcall (pbi->bb, insn, note); else propagate_block_delete_insn (pbi->bb, insn); diff --git a/gcc/jump.c b/gcc/jump.c index 242692143b1..e3ed1b42747 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -2823,16 +2823,15 @@ delete_insn (insn) to special NOTEs instead. When not optimizing, leave them alone. */ if (was_code_label && LABEL_NAME (insn) != 0) { - if (! optimize) - dont_really_delete = 1; - else if (! dont_really_delete) + if (optimize) { const char *name = LABEL_NAME (insn); PUT_CODE (insn, NOTE); NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED_LABEL; NOTE_SOURCE_FILE (insn) = name; - dont_really_delete = 1; } + + dont_really_delete = 1; } else /* Mark this insn as deleted. */ diff --git a/gcc/loop.c b/gcc/loop.c index 3e340af9a93..965f6efa3eb 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -9240,17 +9240,52 @@ try_copy_prop (loop, replacement, regno) fprintf (loop_dump_stream, " Replaced reg %d", regno); if (store_is_first && replaced_last) { - PUT_CODE (init_insn, NOTE); - NOTE_LINE_NUMBER (init_insn) = NOTE_INSN_DELETED; - if (loop_dump_stream) - fprintf (loop_dump_stream, ", deleting init_insn (%d)", - INSN_UID (init_insn)); + rtx first; + rtx retval_note; + + /* Assume we're just deleting INIT_INSN. */ + first = init_insn; + /* Look for REG_RETVAL note. If we're deleting the end of + the libcall sequence, the whole sequence can go. */ + retval_note = find_reg_note (init_insn, REG_RETVAL, NULL_RTX); + /* If we found a REG_RETVAL note, find the first instruction + in the sequence. */ + if (retval_note) + first = XEXP (retval_note, 0); + + /* Delete the instructions. */ + loop_delete_insns (first, init_insn); } if (loop_dump_stream) fprintf (loop_dump_stream, ".\n"); } } +/* Replace all the instructions from FIRST up to and including LAST + with NOTE_INSN_DELETED notes. */ + +static void +loop_delete_insns (first, last) + rtx first; + rtx last; +{ + while (1) + { + PUT_CODE (first, NOTE); + NOTE_LINE_NUMBER (first) = NOTE_INSN_DELETED; + if (loop_dump_stream) + fprintf (loop_dump_stream, ", deleting init_insn (%d)", + INSN_UID (first)); + + /* If this was the LAST instructions we're supposed to delete, + we're done. */ + if (first == last) + break; + + first = NEXT_INSN (first); + } +} + /* Try to replace occurrences of pseudo REGNO with REPLACEMENT within loop LOOP if the order of the sets of these registers can be swapped. There must be exactly one insn within the loop that sets diff --git a/gcc/testsuite/gcc.c-torture/compile/20010421-1.c b/gcc/testsuite/gcc.c-torture/compile/20010421-1.c new file mode 100644 index 00000000000..bec6aa90304 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20010421-1.c @@ -0,0 +1,8 @@ +int j; + +void residual () +{ + long double s; + for (j = 3; j < 9; j++) + s -= 3; +} diff --git a/gcc/unroll.c b/gcc/unroll.c index 52de4996bd4..a0ffa956f23 100644 --- a/gcc/unroll.c +++ b/gcc/unroll.c @@ -1672,7 +1672,7 @@ initial_reg_note_copy (notes, map) XEXP (copy, 0) = copy_rtx_and_substitute (XEXP (notes, 0), map, 0); else if (GET_CODE (notes) == INSN_LIST) /* Don't substitute for these yet. */ - XEXP (copy, 0) = XEXP (notes, 0); + XEXP (copy, 0) = copy_rtx (XEXP (notes, 0)); else abort ();