fix vector constant pooling
Richard Henderson
rth@redhat.com
Sun Jan 30 18:33:00 GMT 2005
I noticed that we were producing a lot of duplicate constants in
the constant pool. First, rtx_equal_p was incorrect since unlike
const_int and const_double, we don't have pointer-unique vectors.
Second, const_rtx_hash does quite a bit better when we actually
compute a hash number for the constant in question.
Tested on x86-64 linux.
r~
* rtl.c (rtx_equal_p): No early exit for CONST_VECTOR.
* varasm.c (const_rtx_hash_1): Handle CONST_VECTOR.
Index: rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.c,v
retrieving revision 1.149
diff -u -p -d -r1.149 rtl.c
--- rtl.c 9 Nov 2004 10:12:19 -0000 1.149
+++ rtl.c 30 Jan 2005 18:07:06 -0000
@@ -364,7 +364,6 @@ rtx_equal_p (rtx x, rtx y)
case SCRATCH:
case CONST_DOUBLE:
case CONST_INT:
- case CONST_VECTOR:
return 0;
default:
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.476
diff -u -p -d -r1.476 varasm.c
--- varasm.c 16 Jan 2005 15:28:16 -0000 1.476
+++ varasm.c 30 Jan 2005 18:07:07 -0000
@@ -2874,6 +2874,14 @@ const_rtx_hash_1 (rtx *xp, void *data)
h ^= real_hash (CONST_DOUBLE_REAL_VALUE (x));
break;
+ case CONST_VECTOR:
+ {
+ int i;
+ for (i = XVECLEN (x, 0); i-- > 0; )
+ h = h * 251 + const_rtx_hash_1 (&XVECEXP (x, 0, i), data);
+ }
+ break;
+
case SYMBOL_REF:
h ^= htab_hash_string (XSTR (x, 0));
break;
More information about the Gcc-patches
mailing list