Makefile.in (emit-rtl.o): Depend on HASHTAB_H.

* Makefile.in (emit-rtl.o): Depend on HASHTAB_H.
	* alias.c (reg_known_value): Add comments.
	(init_alias_analysis): Likewise.
	* cse.c (exp_equiv_p): CONST_INTs are equal iff they have the same
	address.
	(cse_basic_block): Fix typo in comment.
	* emit-rtl.c: Include hashtab.h.
	(const_int_htab): New variable.
	(const_int_htab_hash): New function.
	(const_int_htab_eq): Likewise.
	(rtx_htab_mark_1): Likewise.
	(rtx_htab_mark): Likewise.
	(gen_rtx_CONST_INT): Cache all CONST_INTs.
	(unshare_all_rtx): Fix formatting.
	(init_emit_once): Initialize const_int_htab.
	* rtl.c (rtx_equal_p): CONST_INTs are equal iff they have the same
	address.
	* rtl.texi: Document the fact that all CONST_INTs with the same
	value are shared.

From-SVN: r32844
This commit is contained in:
Mark Mitchell 2000-03-31 08:57:54 +00:00 committed by Mark Mitchell
parent cca8e0ff22
commit c13e821047
7 changed files with 136 additions and 31 deletions

View File

@ -1,3 +1,25 @@
2000-03-30 Mark Mitchell <mark@codesourcery.com>
* Makefile.in (emit-rtl.o): Depend on HASHTAB_H.
* alias.c (reg_known_value): Add comments.
(init_alias_analysis): Likewise.
* cse.c (exp_equiv_p): CONST_INTs are equal iff they have the same
address.
(cse_basic_block): Fix typo in comment.
* emit-rtl.c: Include hashtab.h.
(const_int_htab): New variable.
(const_int_htab_hash): New function.
(const_int_htab_eq): Likewise.
(rtx_htab_mark_1): Likewise.
(rtx_htab_mark): Likewise.
(gen_rtx_CONST_INT): Cache all CONST_INTs.
(unshare_all_rtx): Fix formatting.
(init_emit_once): Initialize const_int_htab.
* rtl.c (rtx_equal_p): CONST_INTs are equal iff they have the same
address.
* rtl.texi: Document the fact that all CONST_INTs with the same
value are shared.
2000-03-30 Richard Henderson <rth@cygnus.com>
* alpha.h (FUNCTION_BOUNDARY): Reduce to 128 bits.

View File

@ -1546,7 +1546,8 @@ xcoffout.o : xcoffout.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) xcoffout.h \
flags.h toplev.h output.h dbxout.h ggc.h
emit-rtl.o : emit-rtl.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \
function.h $(REGS_H) insn-config.h $(RECOG_H) real.h ggc.h \
$(EXPR_H) $(srcdir)/../include/obstack.h hard-reg-set.h bitmap.h toplev.h
$(EXPR_H) $(srcdir)/../include/obstack.h hard-reg-set.h bitmap.h toplev.h \
$(HASHTAB_H)
real.o : real.c $(CONFIG_H) system.h $(TREE_H) toplev.h
integrate.o : integrate.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \
$(INTEGRATE_H) insn-flags.h insn-config.h $(EXPR_H) real.h $(REGS_H) \

View File

@ -153,8 +153,10 @@ static unsigned int reg_base_value_size; /* size of reg_base_value array */
after reload. */
static rtx *alias_invariant;
/* Vector indexed by N giving the initial (unchanging) value known
for pseudo-register N. */
/* Vector indexed by N giving the initial (unchanging) value known for
pseudo-register N. This array is initialized in
init_alias_analysis, and does not change until end_alias_analysis
is called. */
rtx *reg_known_value;
/* Indicates number of valid entries in reg_known_value. */
@ -1570,6 +1572,9 @@ init_alias_once ()
alias_sets = splay_tree_new (splay_tree_compare_ints, 0, 0);
}
/* Initialize the aliasing machinery. Initialize the REG_KNOWN_VALUE
array. */
void
init_alias_analysis ()
{

View File

@ -2367,10 +2367,8 @@ exp_equiv_p (x, y, validate, equal_values)
{
case PC:
case CC0:
return x == y;
case CONST_INT:
return INTVAL (x) == INTVAL (y);
return x == y;
case LABEL_REF:
return XEXP (x, 0) == XEXP (y, 0);
@ -6898,7 +6896,7 @@ cse_basic_block (from, to, next_branch, around_loop)
/* If we have processed 1,000 insns, flush the hash table to
avoid extreme quadratic behavior. We must not include NOTEs
in the count since there may be more or them when generating
in the count since there may be more of them when generating
debugging information. If we clear the table at different
times, code generated with -g -O might be different than code
generated with -O but not -g.

View File

@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA. */
#include "expr.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "hashtab.h"
#include "insn-config.h"
#include "recog.h"
#include "real.h"
@ -137,6 +138,11 @@ rtx return_address_pointer_rtx; /* (REG:Pmode RETURN_ADDRESS_POINTER_REGNUM) */
rtx const_int_rtx[MAX_SAVED_CONST_INT * 2 + 1];
/* A hash table storing CONST_INTs whose absolute value is greater
than MAX_SAVED_CONST_INT. */
static htab_t const_int_htab;
/* start_sequence and gen_sequence can make a lot of rtx expressions which are
shortly thrown away. We use two mechanisms to prevent this waste:
@ -172,16 +178,67 @@ static rtx make_call_insn_raw PARAMS ((rtx));
static rtx find_line_note PARAMS ((rtx));
static void mark_sequence_stack PARAMS ((struct sequence_stack *));
static void unshare_all_rtl_1 PARAMS ((rtx));
static hashval_t const_int_htab_hash PARAMS ((const void *));
static int const_int_htab_eq PARAMS ((const void *,
const void *));
static int rtx_htab_mark_1 PARAMS ((void **, void *));
static void rtx_htab_mark PARAMS ((void *));
/* Returns a hash code for X (which is a really a CONST_INT). */
static hashval_t
const_int_htab_hash (x)
const void *x;
{
return (hashval_t) INTVAL ((rtx) x);
}
/* Returns non-zero if the value represented by X (which is really a
CONST_INT) is the same as that given by Y (which is really a
HOST_WIDE_INT *). */
static int
const_int_htab_eq (x, y)
const void *x;
const void *y;
{
return (INTVAL ((rtx) x) == *((HOST_WIDE_INT *) y));
}
/* Mark the hash-table element X (which is really a pointer to an
rtx). */
static int
rtx_htab_mark_1 (x, data)
void **x;
void *data ATTRIBUTE_UNUSED;
{
ggc_mark_rtx (*x);
return 1;
}
/* Mark all the elements of HTAB (which is really an htab_t full of
rtxs). */
static void
rtx_htab_mark (htab)
void *htab;
{
htab_traverse (*((htab_t *) htab), rtx_htab_mark_1, NULL);
}
/* There are some RTL codes that require special attention; the generation
functions do the raw handling. If you add to this list, modify
special_rtx in gengenrtl.c as well. */
rtx
gen_rtx_CONST_INT (mode, arg)
enum machine_mode mode;
enum machine_mode mode ATTRIBUTE_UNUSED;
HOST_WIDE_INT arg;
{
void **slot;
if (arg >= - MAX_SAVED_CONST_INT && arg <= MAX_SAVED_CONST_INT)
return const_int_rtx[arg + MAX_SAVED_CONST_INT];
@ -190,7 +247,15 @@ gen_rtx_CONST_INT (mode, arg)
return const_true_rtx;
#endif
return gen_rtx_raw_CONST_INT (mode, arg);
/* Look up the CONST_INT in the hash table. */
slot = htab_find_slot_with_hash (const_int_htab,
&arg,
(hashval_t) arg,
/*insert=*/1);
if (!*slot)
*slot = gen_rtx_raw_CONST_INT (VOIDmode, arg);
return (rtx) *slot;
}
/* CONST_DOUBLEs needs special handling because its length is known
@ -1627,9 +1692,7 @@ unshare_all_rtl (fndecl, insn)
/* Make sure that virtual parameters are not shared. */
for (decl = DECL_ARGUMENTS (fndecl); decl; decl = TREE_CHAIN (decl))
{
copy_rtx_if_shared (DECL_RTL (decl));
}
/* Unshare just about everything else. */
unshare_all_rtl_1 (insn);
@ -4083,6 +4146,14 @@ init_emit_once (line_numbers)
ggc_add_rtx_root (&static_chain_rtx, 1);
ggc_add_rtx_root (&static_chain_incoming_rtx, 1);
ggc_add_rtx_root (&return_address_pointer_rtx, 1);
/* Initialize the CONST_INT hash table. */
const_int_htab = htab_create (37,
const_int_htab_hash,
const_int_htab_eq,
NULL);
ggc_add_root (&const_int_htab, 1, sizeof (const_int_htab),
rtx_htab_mark);
}
/* Query and clear/ restore no_line_numbers. This is used by the

View File

@ -613,9 +613,10 @@ rtx_equal_p (x, y)
if (GET_MODE (x) != GET_MODE (y))
return 0;
/* REG, LABEL_REF, and SYMBOL_REF can be compared nonrecursively. */
if (code == REG)
/* Some RTL can be compared nonrecursively. */
switch (code)
{
case REG:
/* Until rtl generation is complete, don't consider a reference to the
return register of the current function the same as the return from a
called function. This eases the job of function integration. Once the
@ -623,13 +624,22 @@ rtx_equal_p (x, y)
return (REGNO (x) == REGNO (y)
&& (! rtx_equal_function_value_matters
|| REG_FUNCTION_VALUE_P (x) == REG_FUNCTION_VALUE_P (y)));
else if (code == LABEL_REF)
case LABEL_REF:
return XEXP (x, 0) == XEXP (y, 0);
else if (code == SYMBOL_REF)
case SYMBOL_REF:
return XSTR (x, 0) == XSTR (y, 0);
else if (code == SCRATCH || code == CONST_DOUBLE)
case SCRATCH:
case CONST_DOUBLE:
case CONST_INT:
return 0;
default:
break;
}
/* Compare the elements. If any pair of corresponding elements
fail to match, return 0 for the whole things. */

View File

@ -1,4 +1,4 @@
@c Copyright (C) 1988, 89, 92, 94, 97, 1998, 1999 Free Software Foundation, Inc.
@c Copyright (C) 1988, 89, 92, 94, 97, 1998, 1999, 2000 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@ -2917,9 +2917,7 @@ referring to it.
@cindex @code{const_int}, RTL sharing
@item
There is only one @code{const_int} expression with value 0, only
one with value 1, and only one with value @minus{}1.
Some other integer values are also stored uniquely.
All @code{const_int} expressions with equal values are shared.
@cindex @code{pc}, RTL sharing
@item