Commit 29c1846b by J"orn Rennecke Committed by Joern Rennecke

re PR rtl-optimization/22445 (Optimizations done by cselib depend on pointer values)

	PR rtl-optimization/22445
	* cselib.c (target.h): Include.
	(rtx_equal_for_cselib_p): Allow commutative matches.
	(cselib_hash_rtx): Don't use MODE for CONST_INT hashing.
	Remove MODE parameter.  Changed all callers.

From-SVN: r102280
parent 45002e59
2005-07-22 J"orn Rennecke <joern.rennecke@st.com> 2005-07-22 J"orn Rennecke <joern.rennecke@st.com>
PR rtl-optimization/22445
* cselib.c (target.h): Include.
(rtx_equal_for_cselib_p): Allow commutative matches.
(cselib_hash_rtx): Don't use MODE for CONST_INT hashing.
Remove MODE parameter. Changed all callers.
PR rtl-optimization/22258 PR rtl-optimization/22258
* combine.c (likely_spilled_retval_1, likely_spilled_retval_p): * combine.c (likely_spilled_retval_1, likely_spilled_retval_p):
New functions. New functions.
......
...@@ -41,6 +41,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -41,6 +41,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "cselib.h" #include "cselib.h"
#include "params.h" #include "params.h"
#include "alloc-pool.h" #include "alloc-pool.h"
#include "target.h"
static bool cselib_record_memory; static bool cselib_record_memory;
static int entry_and_rtx_equal_p (const void *, const void *); static int entry_and_rtx_equal_p (const void *, const void *);
...@@ -54,7 +55,7 @@ static int discard_useless_locs (void **, void *); ...@@ -54,7 +55,7 @@ static int discard_useless_locs (void **, void *);
static int discard_useless_values (void **, void *); static int discard_useless_values (void **, void *);
static void remove_useless_values (void); static void remove_useless_values (void);
static rtx wrap_constant (enum machine_mode, rtx); static rtx wrap_constant (enum machine_mode, rtx);
static unsigned int cselib_hash_rtx (rtx, enum machine_mode, int); static unsigned int cselib_hash_rtx (rtx, int);
static cselib_val *new_cselib_val (unsigned int, enum machine_mode); static cselib_val *new_cselib_val (unsigned int, enum machine_mode);
static void add_mem_for_addr (cselib_val *, cselib_val *, rtx); static void add_mem_for_addr (cselib_val *, cselib_val *, rtx);
static cselib_val *cselib_lookup_mem (rtx, int); static cselib_val *cselib_lookup_mem (rtx, int);
...@@ -499,6 +500,11 @@ rtx_equal_for_cselib_p (rtx x, rtx y) ...@@ -499,6 +500,11 @@ rtx_equal_for_cselib_p (rtx x, rtx y)
break; break;
case 'e': case 'e':
if (i == 1
&& targetm.commutative_p (x, UNKNOWN)
&& rtx_equal_for_cselib_p (XEXP (x, 1), XEXP (y, 0))
&& rtx_equal_for_cselib_p (XEXP (x, 0), XEXP (y, 1)))
return 1;
if (! rtx_equal_for_cselib_p (XEXP (x, i), XEXP (y, i))) if (! rtx_equal_for_cselib_p (XEXP (x, i), XEXP (y, i)))
return 0; return 0;
break; break;
...@@ -546,11 +552,22 @@ wrap_constant (enum machine_mode mode, rtx x) ...@@ -546,11 +552,22 @@ wrap_constant (enum machine_mode mode, rtx x)
Possible reasons for return 0 are: the object is volatile, or we couldn't Possible reasons for return 0 are: the object is volatile, or we couldn't
find a register or memory location in the table and CREATE is zero. If find a register or memory location in the table and CREATE is zero. If
CREATE is nonzero, table elts are created for regs and mem. CREATE is nonzero, table elts are created for regs and mem.
MODE is used in hashing for CONST_INTs only; N.B. this hash function returns the same hash value for RTXes that
otherwise the mode of X is used. */ differ only in the order of operands, thus it is suitable for comparisons
that take commutativity into account.
If we wanted to also support associative rules, we'd have to use a different
strategy to avoid returning spurious 0, e.g. return ~(~0U >> 1) .
We used to have a MODE argument for hashing for CONST_INTs, but that
didn't make sense, since it caused spurious hash differences between
(set (reg:SI 1) (const_int))
(plus:SI (reg:SI 2) (reg:SI 1))
and
(plus:SI (reg:SI 2) (const_int))
If the mode is important in any context, it must be checked specifically
in a comparison anyway, since relying on hash differences is unsafe. */
static unsigned int static unsigned int
cselib_hash_rtx (rtx x, enum machine_mode mode, int create) cselib_hash_rtx (rtx x, int create)
{ {
cselib_val *e; cselib_val *e;
int i, j; int i, j;
...@@ -572,7 +589,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create) ...@@ -572,7 +589,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create)
return e->value; return e->value;
case CONST_INT: case CONST_INT:
hash += ((unsigned) CONST_INT << 7) + (unsigned) mode + INTVAL (x); hash += ((unsigned) CONST_INT << 7) + INTVAL (x);
return hash ? hash : (unsigned int) CONST_INT; return hash ? hash : (unsigned int) CONST_INT;
case CONST_DOUBLE: case CONST_DOUBLE:
...@@ -596,7 +613,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create) ...@@ -596,7 +613,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create)
for (i = 0; i < units; ++i) for (i = 0; i < units; ++i)
{ {
elt = CONST_VECTOR_ELT (x, i); elt = CONST_VECTOR_ELT (x, i);
hash += cselib_hash_rtx (elt, GET_MODE (elt), 0); hash += cselib_hash_rtx (elt, 0);
} }
return hash; return hash;
...@@ -644,7 +661,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create) ...@@ -644,7 +661,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create)
case 'e': case 'e':
{ {
rtx tem = XEXP (x, i); rtx tem = XEXP (x, i);
unsigned int tem_hash = cselib_hash_rtx (tem, 0, create); unsigned int tem_hash = cselib_hash_rtx (tem, create);
if (tem_hash == 0) if (tem_hash == 0)
return 0; return 0;
...@@ -656,7 +673,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create) ...@@ -656,7 +673,7 @@ cselib_hash_rtx (rtx x, enum machine_mode mode, int create)
for (j = 0; j < XVECLEN (x, i); j++) for (j = 0; j < XVECLEN (x, i); j++)
{ {
unsigned int tem_hash unsigned int tem_hash
= cselib_hash_rtx (XVECEXP (x, i, j), 0, create); = cselib_hash_rtx (XVECEXP (x, i, j), create);
if (tem_hash == 0) if (tem_hash == 0)
return 0; return 0;
...@@ -936,7 +953,7 @@ cselib_lookup (rtx x, enum machine_mode mode, int create) ...@@ -936,7 +953,7 @@ cselib_lookup (rtx x, enum machine_mode mode, int create)
if (MEM_P (x)) if (MEM_P (x))
return cselib_lookup_mem (x, create); return cselib_lookup_mem (x, create);
hashval = cselib_hash_rtx (x, mode, create); hashval = cselib_hash_rtx (x, create);
/* Can't even create if hashing is not possible. */ /* Can't even create if hashing is not possible. */
if (! hashval) if (! hashval)
return 0; return 0;
......
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