aboutsummaryrefslogtreecommitdiff
path: root/gcc/cse.c
diff options
context:
space:
mode:
authorKazu Hirata <kazu@cs.umass.edu>2005-01-31 22:43:36 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2005-01-31 22:43:36 +0000
commit65e9fa1009c4d715363af095e40d954293644315 (patch)
tree2249e41ab8a2583dd2f7801ca7b005192ea32e47 /gcc/cse.c
parent0530bc70fbab2126ca2510ca18b61d01f949f38d (diff)
downloadgcc-65e9fa1009c4d715363af095e40d954293644315.zip
gcc-65e9fa1009c4d715363af095e40d954293644315.tar.gz
gcc-65e9fa1009c4d715363af095e40d954293644315.tar.bz2
* cse.c (delete_trivially_dead_insn): Don't iterate.
From-SVN: r94498
Diffstat (limited to 'gcc/cse.c')
-rw-r--r--gcc/cse.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/gcc/cse.c b/gcc/cse.c
index 427ab0b..ca0bade 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -7268,7 +7268,7 @@ delete_trivially_dead_insns (rtx insns, int nreg)
int *counts;
rtx insn, prev;
int in_libcall = 0, dead_libcall = 0;
- int ndead = 0, nlastdead, niterations = 0;
+ int ndead = 0;
timevar_push (TV_DELETE_TRIVIALLY_DEAD);
/* First count the number of times each register is used. */
@@ -7276,65 +7276,59 @@ delete_trivially_dead_insns (rtx insns, int nreg)
for (insn = next_real_insn (insns); insn; insn = next_real_insn (insn))
count_reg_usage (insn, counts, 1);
- do
- {
- nlastdead = ndead;
- niterations++;
- /* Go from the last insn to the first and delete insns that only set unused
- registers or copy a register to itself. As we delete an insn, remove
- usage counts for registers it uses.
-
- The first jump optimization pass may leave a real insn as the last
- insn in the function. We must not skip that insn or we may end
- up deleting code that is not really dead. */
- insn = get_last_insn ();
- if (! INSN_P (insn))
- insn = prev_real_insn (insn);
+ /* Go from the last insn to the first and delete insns that only set unused
+ registers or copy a register to itself. As we delete an insn, remove
+ usage counts for registers it uses.
- for (; insn; insn = prev)
- {
- int live_insn = 0;
+ The first jump optimization pass may leave a real insn as the last
+ insn in the function. We must not skip that insn or we may end
+ up deleting code that is not really dead. */
+ insn = get_last_insn ();
+ if (! INSN_P (insn))
+ insn = prev_real_insn (insn);
- prev = prev_real_insn (insn);
+ for (; insn; insn = prev)
+ {
+ int live_insn = 0;
- /* Don't delete any insns that are part of a libcall block unless
- we can delete the whole libcall block.
+ prev = prev_real_insn (insn);
- Flow or loop might get confused if we did that. Remember
- that we are scanning backwards. */
- if (find_reg_note (insn, REG_RETVAL, NULL_RTX))
- {
- in_libcall = 1;
- live_insn = 1;
- dead_libcall = dead_libcall_p (insn, counts);
- }
- else if (in_libcall)
- live_insn = ! dead_libcall;
- else
- live_insn = insn_live_p (insn, counts);
+ /* Don't delete any insns that are part of a libcall block unless
+ we can delete the whole libcall block.
+
+ Flow or loop might get confused if we did that. Remember
+ that we are scanning backwards. */
+ if (find_reg_note (insn, REG_RETVAL, NULL_RTX))
+ {
+ in_libcall = 1;
+ live_insn = 1;
+ dead_libcall = dead_libcall_p (insn, counts);
+ }
+ else if (in_libcall)
+ live_insn = ! dead_libcall;
+ else
+ live_insn = insn_live_p (insn, counts);
- /* If this is a dead insn, delete it and show registers in it aren't
- being used. */
+ /* If this is a dead insn, delete it and show registers in it aren't
+ being used. */
- if (! live_insn)
- {
- count_reg_usage (insn, counts, -1);
- delete_insn_and_edges (insn);
- ndead++;
- }
+ if (! live_insn)
+ {
+ count_reg_usage (insn, counts, -1);
+ delete_insn_and_edges (insn);
+ ndead++;
+ }
- if (find_reg_note (insn, REG_LIBCALL, NULL_RTX))
- {
- in_libcall = 0;
- dead_libcall = 0;
- }
+ if (find_reg_note (insn, REG_LIBCALL, NULL_RTX))
+ {
+ in_libcall = 0;
+ dead_libcall = 0;
}
}
- while (ndead != nlastdead);
if (dump_file && ndead)
- fprintf (dump_file, "Deleted %i trivially dead insns; %i iterations\n",
- ndead, niterations);
+ fprintf (dump_file, "Deleted %i trivially dead insns\n",
+ ndead);
/* Clean up. */
free (counts);
timevar_pop (TV_DELETE_TRIVIALLY_DEAD);