Commit 0618dee5 by Alexandre Oliva Committed by Alexandre Oliva

re PR debug/59992 (Compilation of insn-recog.c too slow due to var-tracking)

PR debug/59992
* cselib.c (cselib_hasher::equal): Special-case VALUE lookup.
(cselib_preserved_hash_table): New.
(preserve_constants_and_equivs): Move preserved vals to it.
(cselib_find_slot): Look it up first.
(cselib_init): Initialize it.
(cselib_finish): Release it.
(dump_cselib_table): Dump it.

From-SVN: r208221
parent 22414f3f
2014-02-28 Alexandre Oliva <aoliva@redhat.com> 2014-02-28 Alexandre Oliva <aoliva@redhat.com>
PR debug/59992 PR debug/59992
* cselib.c (cselib_hasher::equal): Special-case VALUE lookup.
(cselib_preserved_hash_table): New.
(preserve_constants_and_equivs): Move preserved vals to it.
(cselib_find_slot): Look it up first.
(cselib_init): Initialize it.
(cselib_finish): Release it.
(dump_cselib_table): Dump it.
2014-02-28 Alexandre Oliva <aoliva@redhat.com>
PR debug/59992
* cselib.c (remove_useless_values): Skip to avoid quadratic * cselib.c (remove_useless_values): Skip to avoid quadratic
behavior if the condition moved from... behavior if the condition moved from...
(cselib_process_insn): ... here holds. (cselib_process_insn): ... here holds.
......
...@@ -132,6 +132,9 @@ cselib_hasher::equal (const value_type *v, const compare_type *x_arg) ...@@ -132,6 +132,9 @@ cselib_hasher::equal (const value_type *v, const compare_type *x_arg)
|| GET_CODE (XEXP (x, 0)) == CONST_FIXED)) || GET_CODE (XEXP (x, 0)) == CONST_FIXED))
x = XEXP (x, 0); x = XEXP (x, 0);
if (GET_CODE (x) == VALUE)
return x == v->val_rtx;
/* We don't guarantee that distinct rtx's have different hash values, /* We don't guarantee that distinct rtx's have different hash values,
so we need to do a comparison. */ so we need to do a comparison. */
for (l = v->locs; l; l = l->next) for (l = v->locs; l; l = l->next)
...@@ -147,6 +150,9 @@ cselib_hasher::equal (const value_type *v, const compare_type *x_arg) ...@@ -147,6 +150,9 @@ cselib_hasher::equal (const value_type *v, const compare_type *x_arg)
/* A table that enables us to look up elts by their value. */ /* A table that enables us to look up elts by their value. */
static hash_table <cselib_hasher> cselib_hash_table; static hash_table <cselib_hasher> cselib_hash_table;
/* A table to hold preserved values. */
static hash_table <cselib_hasher> cselib_preserved_hash_table;
/* This is a global so we don't have to pass this through every function. /* This is a global so we don't have to pass this through every function.
It is used in new_elt_loc_list to set SETTING_INSN. */ It is used in new_elt_loc_list to set SETTING_INSN. */
static rtx cselib_current_insn; static rtx cselib_current_insn;
...@@ -490,8 +496,17 @@ preserve_constants_and_equivs (cselib_val **x, void *info ATTRIBUTE_UNUSED) ...@@ -490,8 +496,17 @@ preserve_constants_and_equivs (cselib_val **x, void *info ATTRIBUTE_UNUSED)
{ {
cselib_val *v = *x; cselib_val *v = *x;
if (!invariant_or_equiv_p (v)) if (invariant_or_equiv_p (v))
{
cselib_val **slot
= cselib_preserved_hash_table.find_slot_with_hash (v->val_rtx,
v->hash, INSERT);
gcc_assert (!*slot);
*slot = v;
}
cselib_hash_table.clear_slot (x); cselib_hash_table.clear_slot (x);
return 1; return 1;
} }
...@@ -565,8 +580,12 @@ static cselib_val ** ...@@ -565,8 +580,12 @@ static cselib_val **
cselib_find_slot (rtx x, hashval_t hash, enum insert_option insert, cselib_find_slot (rtx x, hashval_t hash, enum insert_option insert,
enum machine_mode memmode) enum machine_mode memmode)
{ {
cselib_val **slot; cselib_val **slot = NULL;
find_slot_memmode = memmode; find_slot_memmode = memmode;
if (cselib_preserve_constants)
slot = cselib_preserved_hash_table.find_slot_with_hash (x, hash,
NO_INSERT);
if (!slot)
slot = cselib_hash_table.find_slot_with_hash (x, hash, insert); slot = cselib_hash_table.find_slot_with_hash (x, hash, insert);
find_slot_memmode = VOIDmode; find_slot_memmode = VOIDmode;
return slot; return slot;
...@@ -2742,6 +2761,8 @@ cselib_init (int record_what) ...@@ -2742,6 +2761,8 @@ cselib_init (int record_what)
used_regs = XNEWVEC (unsigned int, cselib_nregs); used_regs = XNEWVEC (unsigned int, cselib_nregs);
n_used_regs = 0; n_used_regs = 0;
cselib_hash_table.create (31); cselib_hash_table.create (31);
if (cselib_preserve_constants)
cselib_preserved_hash_table.create (31);
next_uid = 1; next_uid = 1;
} }
...@@ -2750,6 +2771,7 @@ cselib_init (int record_what) ...@@ -2750,6 +2771,7 @@ cselib_init (int record_what)
void void
cselib_finish (void) cselib_finish (void)
{ {
bool preserved = cselib_preserve_constants;
cselib_discard_hook = NULL; cselib_discard_hook = NULL;
cselib_preserve_constants = false; cselib_preserve_constants = false;
cselib_any_perm_equivs = false; cselib_any_perm_equivs = false;
...@@ -2761,6 +2783,8 @@ cselib_finish (void) ...@@ -2761,6 +2783,8 @@ cselib_finish (void)
free_alloc_pool (value_pool); free_alloc_pool (value_pool);
cselib_clear_table (); cselib_clear_table ();
cselib_hash_table.dispose (); cselib_hash_table.dispose ();
if (preserved)
cselib_preserved_hash_table.dispose ();
free (used_regs); free (used_regs);
used_regs = 0; used_regs = 0;
n_useless_values = 0; n_useless_values = 0;
...@@ -2850,6 +2874,8 @@ dump_cselib_table (FILE *out) ...@@ -2850,6 +2874,8 @@ dump_cselib_table (FILE *out)
{ {
fprintf (out, "cselib hash table:\n"); fprintf (out, "cselib hash table:\n");
cselib_hash_table.traverse <FILE *, dump_cselib_val> (out); cselib_hash_table.traverse <FILE *, dump_cselib_val> (out);
fprintf (out, "cselib preserved hash table:\n");
cselib_preserved_hash_table.traverse <FILE *, dump_cselib_val> (out);
if (first_containing_mem != &dummy_val) if (first_containing_mem != &dummy_val)
{ {
fputs ("first mem ", out); fputs ("first mem ", out);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment