PR debug/42896
* cselib.h (struct cselib_val_struct): Add uid. Rename value to
hash.
(cselib_reset_table): Renamed from...
(cselib_reset_table_with_next_value): ... this.
(cselib_get_next_uid): Renamed from...
(cselib_get_next_unknown_value): ... this.
* cselib.c (next_uid): Renamed from...
(next_unknown_value): ... this.
(cselib_clear_table): Adjust.
(cselib_reset_table): Adjust. Renamed from...
(cselib_reset_table_with_next_value): ... this.
(cselib_get_next_uid): Adjust. Renamed from...
(cselib_get_next_unknown_value): ... this.
(get_value_hash): Use hash.
(cselib_hash_rtx): Likewise.
(new_cselib_val): Adjust. Set and dump uid.
(cselib_lookup_mem): Pass next_uid as hash.
(cselib_subst_to_values): Likewise.
(cselib_log_lookup): Dump uid.
(cselib_lookup): Pass next_uid as hash. Adjust.
(cselib_process_insn): Adjust.
(cselib_init): Initialize next_uid.
(cselib_finish): Adjust.
(dump_cselib_table): Likewise.
* dse.c (canon_address): Dump value uid.
* print-rtl.c (print_rtx): Print value uid.
* var-tracking.c (VARIABLE_HASH_VAL): Dropped.
(dvuid): New type.
(dv_uid): New function, sort of renamed from...
(dv_htab_hash): ... this, reimplemented in terms of it and...
(dv_uid2hash): ... this. New.
(variable_htab_eq): Drop excess assertions.
(tie_break_pointers): Removed.
(canon_value_cmp): Compare uids.
(variable_post_merge_New_vals): Print uids.
(vt_add_function_parameters): Adjust.
(vt_initialize): Reset table. Adjust.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156468
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-02-03 Alexandre Oliva <aoliva@redhat.com>
+
+ PR debug/42896
+ * cselib.h (struct cselib_val_struct): Add uid. Rename value to
+ hash.
+ (cselib_reset_table): Renamed from...
+ (cselib_reset_table_with_next_value): ... this.
+ (cselib_get_next_uid): Renamed from...
+ (cselib_get_next_unknown_value): ... this.
+ * cselib.c (next_uid): Renamed from...
+ (next_unknown_value): ... this.
+ (cselib_clear_table): Adjust.
+ (cselib_reset_table): Adjust. Renamed from...
+ (cselib_reset_table_with_next_value): ... this.
+ (cselib_get_next_uid): Adjust. Renamed from...
+ (cselib_get_next_unknown_value): ... this.
+ (get_value_hash): Use hash.
+ (cselib_hash_rtx): Likewise.
+ (new_cselib_val): Adjust. Set and dump uid.
+ (cselib_lookup_mem): Pass next_uid as hash.
+ (cselib_subst_to_values): Likewise.
+ (cselib_log_lookup): Dump uid.
+ (cselib_lookup): Pass next_uid as hash. Adjust.
+ (cselib_process_insn): Adjust.
+ (cselib_init): Initialize next_uid.
+ (cselib_finish): Adjust.
+ (dump_cselib_table): Likewise.
+ * dse.c (canon_address): Dump value uid.
+ * print-rtl.c (print_rtx): Print value uid.
+ * var-tracking.c (VARIABLE_HASH_VAL): Dropped.
+ (dvuid): New type.
+ (dv_uid): New function, sort of renamed from...
+ (dv_htab_hash): ... this, reimplemented in terms of it and...
+ (dv_uid2hash): ... this. New.
+ (variable_htab_eq): Drop excess assertions.
+ (tie_break_pointers): Removed.
+ (canon_value_cmp): Compare uids.
+ (variable_post_merge_New_vals): Print uids.
+ (vt_add_function_parameters): Adjust.
+ (vt_initialize): Reset table. Adjust.
+
2010-02-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42944
It is used in new_elt_loc_list to set SETTING_INSN. */
static rtx cselib_current_insn;
-/* Every new unknown value gets a unique number. */
-static unsigned int next_unknown_value;
+/* The unique id that the next create value will take. */
+static unsigned int next_uid;
/* The number of registers we had when the varrays were last resized. */
static unsigned int cselib_nregs;
void
cselib_clear_table (void)
{
- cselib_reset_table_with_next_value (0);
+ cselib_reset_table (1);
}
/* Remove all entries from the hash table, arranging for the next
value to be numbered NUM. */
void
-cselib_reset_table_with_next_value (unsigned int num)
+cselib_reset_table (unsigned int num)
{
unsigned int i;
n_useless_values = 0;
- next_unknown_value = num;
+ next_uid = num;
first_containing_mem = &dummy_val;
}
/* Return the number of the next value that will be generated. */
unsigned int
-cselib_get_next_unknown_value (void)
+cselib_get_next_uid (void)
{
- return next_unknown_value;
+ return next_uid;
}
/* The equality test for our hash table. The first argument ENTRY is a table
get_value_hash (const void *entry)
{
const cselib_val *const v = (const cselib_val *) entry;
- return v->value;
+ return v->hash;
}
/* Return true if X contains a VALUE rtx. If ONLY_USELESS is set, we
if (! e)
return 0;
- return e->value;
+ return e->hash;
case DEBUG_EXPR:
hash += ((unsigned) DEBUG_EXPR << 7)
value is MODE. */
static inline cselib_val *
-new_cselib_val (unsigned int value, enum machine_mode mode, rtx x)
+new_cselib_val (unsigned int hash, enum machine_mode mode, rtx x)
{
cselib_val *e = (cselib_val *) pool_alloc (cselib_val_pool);
- gcc_assert (value);
+ gcc_assert (hash);
+ gcc_assert (next_uid);
- e->value = value;
+ e->hash = hash;
+ e->uid = next_uid++;
/* We use an alloc pool to allocate this RTL construct because it
accounts for about 8% of the overall memory usage. We know
precisely when we can have VALUE RTXen (when cselib is active)
if (dump_file && (dump_flags & TDF_DETAILS))
{
- fprintf (dump_file, "cselib value %u ", value);
+ fprintf (dump_file, "cselib value %u:%u ", e->uid, hash);
if (flag_dump_noaddr || flag_dump_unnumbered)
fputs ("# ", dump_file);
else
if (! create)
return 0;
- mem_elt = new_cselib_val (++next_unknown_value, mode, x);
+ mem_elt = new_cselib_val (next_uid, mode, x);
add_mem_for_addr (addr, mem_elt, x);
slot = htab_find_slot_with_hash (cselib_hash_table, wrap_constant (mode, x),
- mem_elt->value, INSERT);
+ mem_elt->hash, INSERT);
*slot = mem_elt;
return mem_elt;
}
{
/* This happens for autoincrements. Assign a value that doesn't
match any other. */
- e = new_cselib_val (++next_unknown_value, GET_MODE (x), x);
+ e = new_cselib_val (next_uid, GET_MODE (x), x);
}
return e->val_rtx;
case PRE_DEC:
case POST_MODIFY:
case PRE_MODIFY:
- e = new_cselib_val (++next_unknown_value, GET_MODE (x), x);
+ e = new_cselib_val (next_uid, GET_MODE (x), x);
return e->val_rtx;
default:
{
fputs ("cselib lookup ", dump_file);
print_inline_rtx (dump_file, x, 2);
- fprintf (dump_file, " => %u\n", ret ? ret->value : 0);
+ fprintf (dump_file, " => %u:%u\n",
+ ret ? ret->uid : 0,
+ ret ? ret->hash : 0);
}
return ret;
max_value_regs = n;
}
- e = new_cselib_val (++next_unknown_value, GET_MODE (x), x);
+ e = new_cselib_val (next_uid, GET_MODE (x), x);
e->locs = new_elt_loc_list (e->locs, x);
if (REG_VALUES (i) == 0)
{
REG_VALUES (i) = new_elt_list (REG_VALUES (i), NULL);
}
REG_VALUES (i)->next = new_elt_list (REG_VALUES (i)->next, e);
- slot = htab_find_slot_with_hash (cselib_hash_table, x, e->value, INSERT);
+ slot = htab_find_slot_with_hash (cselib_hash_table, x, e->hash, INSERT);
*slot = e;
return cselib_log_lookup (x, e);
}
&& GET_CODE (PATTERN (insn)) == ASM_OPERANDS
&& MEM_VOLATILE_P (PATTERN (insn))))
{
- cselib_reset_table_with_next_value (next_unknown_value);
+ cselib_reset_table (next_uid);
return;
}
n_used_regs = 0;
cselib_hash_table = htab_create (31, get_value_hash,
entry_and_rtx_equal_p, NULL);
+ next_uid = 1;
}
/* Called when the current user is done with cselib. */
used_regs = 0;
cselib_hash_table = 0;
n_useless_values = 0;
- next_unknown_value = 0;
+ next_uid = 0;
}
/* Dump the cselib_val *X to FILE *info. */
print_inline_rtx (out, first_containing_mem->val_rtx, 2);
fputc ('\n', out);
}
- fprintf (out, "last unknown value %i\n", next_unknown_value);
+ fprintf (out, "next uid %i\n", next_uid);
}
#include "gt-cselib.h"
/* Common subexpression elimination for GNU compiler.
- Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
+ 1998, 1999, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GCC.
/* Describe a value. */
typedef struct GTY(()) cselib_val_struct {
/* The hash value. */
- unsigned int value;
+ unsigned int hash;
+
+ /* A unique id assigned to values. */
+ int uid;
/* A VALUE rtx that points back to this structure. */
rtx val_rtx;
extern rtx cselib_subst_to_values (rtx);
extern void cselib_invalidate_rtx (rtx);
-extern void cselib_reset_table_with_next_value (unsigned int);
-extern unsigned int cselib_get_next_unknown_value (void);
+extern void cselib_reset_table (unsigned int);
+extern unsigned int cselib_get_next_uid (void);
extern void cselib_preserve_value (cselib_val *);
extern bool cselib_preserved_value_p (cselib_val *);
extern void cselib_preserve_only_values (bool);
return false;
}
if (dump_file)
- fprintf (dump_file, " varying cselib base=%d offset = %d\n",
- (*base)->value, (int)*offset);
+ fprintf (dump_file, " varying cselib base=%u:%u offset = %d\n",
+ (*base)->uid, (*base)->hash, (int)*offset);
return true;
}
#ifndef GENERATOR_FILE
cselib_val *val = CSELIB_VAL_PTR (in_rtx);
- fprintf (outfile, " %i", val->value);
+ fprintf (outfile, " %u:%u", val->uid, val->hash);
dump_addr (outfile, " @", in_rtx);
dump_addr (outfile, "/", (void*)val);
#endif
} *value_chain;
typedef const struct value_chain_def *const_value_chain;
-/* Hash function for DECL for VARIABLE_HTAB. */
-#define VARIABLE_HASH_VAL(decl) (DECL_UID (decl))
-
/* Pointer to the BB's information specific to variable tracking pass. */
#define VTI(BB) ((variable_tracking_info) (BB)->aux)
return dv;
}
-static inline hashval_t
-dv_htab_hash (decl_or_value dv)
+typedef unsigned int dvuid;
+
+/* Return the uid of DV. */
+
+static inline dvuid
+dv_uid (decl_or_value dv)
{
if (dv_is_value_p (dv))
- return -(hashval_t)(CSELIB_VAL_PTR (dv_as_value (dv))->value);
+ return CSELIB_VAL_PTR (dv_as_value (dv))->uid;
else
- return (VARIABLE_HASH_VAL (dv_as_decl (dv)));
+ return DECL_UID (dv_as_decl (dv));
+}
+
+/* Compute the hash from the uid. */
+
+static inline hashval_t
+dv_uid2hash (dvuid uid)
+{
+ return uid;
+}
+
+/* The hash function for a mask table in a shared_htab chain. */
+
+static inline hashval_t
+dv_htab_hash (decl_or_value dv)
+{
+ return dv_uid2hash (dv_uid (dv));
}
/* The hash function for variable_htab, computes the hash value
const_variable const v = (const_variable) x;
decl_or_value dv = CONST_CAST2 (decl_or_value, const void *, y);
- if (dv_as_opaque (v->dv) == dv_as_opaque (dv))
- return true;
-
-#if ENABLE_CHECKING
- {
- bool visv, dvisv;
-
- visv = dv_is_value_p (v->dv);
- dvisv = dv_is_value_p (dv);
-
- if (visv != dvisv)
- return false;
-
- if (visv)
- gcc_assert (CSELIB_VAL_PTR (dv_as_value (v->dv))
- != CSELIB_VAL_PTR (dv_as_value (dv)));
- else
- gcc_assert (VARIABLE_HASH_VAL (dv_as_decl (v->dv))
- != VARIABLE_HASH_VAL (dv_as_decl (dv)));
- }
-#endif
-
- return false;
+ return (dv_as_opaque (v->dv) == dv_as_opaque (dv));
}
/* Free the element of VARIABLE_HTAB (its type is struct variable_def). */
return shared_hash_find_1 (vars, dv, dv_htab_hash (dv));
}
-/* Determine a total order between two distinct pointers. Compare the
- pointers as integral types if size_t is wide enough, otherwise
- resort to bitwise memory compare. The actual order does not
- matter, we just need to be consistent, so endianness is
- irrelevant. */
-
-static int
-tie_break_pointers (const void *p1, const void *p2)
-{
- gcc_assert (p1 != p2);
-
- if (sizeof (size_t) >= sizeof (void*))
- return (size_t)p1 < (size_t)p2 ? -1 : 1;
- else
- return memcmp (&p1, &p2, sizeof (p1));
-}
-
/* Return true if TVAL is better than CVAL as a canonival value. We
choose lowest-numbered VALUEs, using the RTX address as a
tie-breaker. The idea is to arrange them into a star topology,
canon_value_cmp (rtx tval, rtx cval)
{
return !cval
- || CSELIB_VAL_PTR (tval)->value < CSELIB_VAL_PTR (cval)->value
- || (CSELIB_VAL_PTR (tval)->value == CSELIB_VAL_PTR (cval)->value
- && tie_break_pointers (tval, cval) < 0);
+ || CSELIB_VAL_PTR (tval)->uid < CSELIB_VAL_PTR (cval)->uid;
}
static bool dst_can_be_shared;
cdv = dv_from_value (cval);
if (dump_file)
fprintf (dump_file,
- "Created new value %i for reg %i\n",
- v->value, REGNO (node->loc));
+ "Created new value %u:%u for reg %i\n",
+ v->uid, v->hash, REGNO (node->loc));
}
var_reg_decl_set (*dfpm->permp, node->loc,
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_preserve_only_values (true);
- cselib_reset_table_with_next_value (cselib_get_next_unknown_value ());
+ cselib_reset_table (cselib_get_next_uid ());
}
}
rtx insn;
HOST_WIDE_INT pre, post = 0;
int count;
- unsigned int next_value_before = cselib_get_next_unknown_value ();
- unsigned int next_value_after = next_value_before;
+ unsigned int next_uid_before = cselib_get_next_uid ();
+ unsigned int next_uid_after = next_uid_before;
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_record_sets_hook = count_with_sets;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "first value: %i\n",
- cselib_get_next_unknown_value ());
+ cselib_get_next_uid ());
}
/* Count the number of micro operations. */
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_preserve_only_values (false);
- next_value_after = cselib_get_next_unknown_value ();
- cselib_reset_table_with_next_value (next_value_before);
+ next_uid_after = cselib_get_next_uid ();
+ cselib_reset_table (next_uid_before);
cselib_record_sets_hook = add_with_sets;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "first value: %i\n",
- cselib_get_next_unknown_value ());
+ cselib_get_next_uid ());
}
/* Add the micro-operations to the array. */
if (MAY_HAVE_DEBUG_INSNS)
{
cselib_preserve_only_values (true);
- gcc_assert (next_value_after == cselib_get_next_unknown_value ());
- cselib_reset_table_with_next_value (next_value_after);
+ gcc_assert (next_uid_after == cselib_get_next_uid ());
+ cselib_reset_table (next_uid_after);
cselib_record_sets_hook = NULL;
}
}