diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-29 18:55:10 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-29 18:55:10 +0000 |
commit | 77780ba6c6322839c0eac40dad8590b361d0fbb4 (patch) | |
tree | a2bcdbd92e2f4f542935cfcb454ae205796cba28 | |
parent | 67d1f463dc8177255d883c6bd55b7d23db86bdad (diff) | |
download | gcc-77780ba6c6322839c0eac40dad8590b361d0fbb4.tar.gz |
* gcse.c (insert_expr_in_table): Revamp handling of available
and anticipatable occurrence lists to avoid unnecessary list
walking.
(insert_set_in_table): Similarly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94413 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/gcse.c | 82 |
2 files changed, 30 insertions, 59 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3edb6156a3c..601ef3d95ee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-01-29 Jeff Law <law@redhat.com> + + * gcse.c (insert_expr_in_table): Revamp handling of available + and anticipatable occurrence lists to avoid unnecessary list + walking. + (insert_set_in_table): Similarly. + 2005-01-29 Joseph S. Myers <joseph@codesourcery.com> * c-common.c (fix_string_type): Just use c_build_qualified_type to diff --git a/gcc/gcse.c b/gcc/gcse.c index b0bd3993d64..118959b2393 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -1504,7 +1504,6 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, unsigned int hash; struct expr *cur_expr, *last_expr = NULL; struct occr *antic_occr, *avail_occr; - struct occr *last_occr = NULL; hash = hash_expr (x, mode, &do_not_record_p, table->size); @@ -1549,14 +1548,8 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, { antic_occr = cur_expr->antic_occr; - /* Search for another occurrence in the same basic block. */ - while (antic_occr && BLOCK_NUM (antic_occr->insn) != BLOCK_NUM (insn)) - { - /* If an occurrence isn't found, save a pointer to the end of - the list. */ - last_occr = antic_occr; - antic_occr = antic_occr->next; - } + if (antic_occr && BLOCK_NUM (antic_occr->insn) != BLOCK_NUM (insn)) + antic_occr = NULL; if (antic_occr) /* Found another instance of the expression in the same basic block. @@ -1568,15 +1561,10 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, /* First occurrence of this expression in this basic block. */ antic_occr = gcse_alloc (sizeof (struct occr)); bytes_used += sizeof (struct occr); - /* First occurrence of this expression in any block? */ - if (cur_expr->antic_occr == NULL) - cur_expr->antic_occr = antic_occr; - else - last_occr->next = antic_occr; - antic_occr->insn = insn; - antic_occr->next = NULL; + antic_occr->next = cur_expr->antic_occr; antic_occr->deleted_p = 0; + cur_expr->antic_occr = antic_occr; } } @@ -1584,36 +1572,23 @@ insert_expr_in_table (rtx x, enum machine_mode mode, rtx insn, int antic_p, { avail_occr = cur_expr->avail_occr; - /* Search for another occurrence in the same basic block. */ - while (avail_occr && BLOCK_NUM (avail_occr->insn) != BLOCK_NUM (insn)) + if (avail_occr && BLOCK_NUM (avail_occr->insn) == BLOCK_NUM (insn)) { - /* If an occurrence isn't found, save a pointer to the end of - the list. */ - last_occr = avail_occr; - avail_occr = avail_occr->next; + /* Found another instance of the expression in the same basic block. + Prefer this occurrence to the currently recorded one. We want + the last one in the block and the block is scanned from start + to end. */ + avail_occr->insn = insn; } - - if (avail_occr) - /* Found another instance of the expression in the same basic block. - Prefer this occurrence to the currently recorded one. We want - the last one in the block and the block is scanned from start - to end. */ - avail_occr->insn = insn; else { /* First occurrence of this expression in this basic block. */ avail_occr = gcse_alloc (sizeof (struct occr)); bytes_used += sizeof (struct occr); - - /* First occurrence of this expression in any block? */ - if (cur_expr->avail_occr == NULL) - cur_expr->avail_occr = avail_occr; - else - last_occr->next = avail_occr; - avail_occr->insn = insn; - avail_occr->next = NULL; + avail_occr->next = cur_expr->avail_occr; avail_occr->deleted_p = 0; + cur_expr->avail_occr = avail_occr; } } } @@ -1629,7 +1604,7 @@ insert_set_in_table (rtx x, rtx insn, struct hash_table *table) int found; unsigned int hash; struct expr *cur_expr, *last_expr = NULL; - struct occr *cur_occr, *last_occr = NULL; + struct occr *cur_occr; gcc_assert (GET_CODE (x) == SET && REG_P (SET_DEST (x))); @@ -1670,35 +1645,24 @@ insert_set_in_table (rtx x, rtx insn, struct hash_table *table) /* Now record the occurrence. */ cur_occr = cur_expr->avail_occr; - /* Search for another occurrence in the same basic block. */ - while (cur_occr && BLOCK_NUM (cur_occr->insn) != BLOCK_NUM (insn)) + if (cur_occr && BLOCK_NUM (cur_occr->insn) == BLOCK_NUM (insn)) { - /* If an occurrence isn't found, save a pointer to the end of - the list. */ - last_occr = cur_occr; - cur_occr = cur_occr->next; + /* Found another instance of the expression in the same basic block. + Prefer this occurrence to the currently recorded one. We want + the last one in the block and the block is scanned from start + to end. */ + cur_occr->insn = insn; } - - if (cur_occr) - /* Found another instance of the expression in the same basic block. - Prefer this occurrence to the currently recorded one. We want the - last one in the block and the block is scanned from start to end. */ - cur_occr->insn = insn; else { /* First occurrence of this expression in this basic block. */ cur_occr = gcse_alloc (sizeof (struct occr)); bytes_used += sizeof (struct occr); - /* First occurrence of this expression in any block? */ - if (cur_expr->avail_occr == NULL) - cur_expr->avail_occr = cur_occr; - else - last_occr->next = cur_occr; - - cur_occr->insn = insn; - cur_occr->next = NULL; - cur_occr->deleted_p = 0; + cur_occr->insn = insn; + cur_occr->next = cur_expr->avail_occr; + cur_occr->deleted_p = 0; + cur_expr->avail_occr = cur_occr; } } |