This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [vta,trunk?] stabilize hashing of SSA names and builtin function DECLs


On Dec 10, 2008, "Richard Guenther" <richard.guenther@gmail.com> wrote:

> On Wed, Dec 10, 2008 at 4:59 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>> On Wed, Oct 29, 2008 at 8:19 PM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>>> On Oct 29, 2008, "Richard Guenther" <richard.guenther@gmail.com> wrote:
>>>> 
>>>>> +      val = iterative_hash_host_wide_int (DECL_UID (SSA_NAME_VAR (t)), val);
>>>>> +      val = iterative_hash_host_wide_int (SSA_NAME_VERSION (t), val);

>> I see.  It doesn't seem to occur any more, but there's little point in
>> doing more work when there's no indication it provides for better
>> hashing *and* it might also hurt.  So, here's an updated patch.  I
>> guess it's too late to fix this kind of bug in 4.4, though.  Anyhow,
>> ok for 4.5?

> Ok for 4.5.

Here's the patch I've just retested, and I'm now checking it in.

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree.c (iterative_hash_pointer): Delete.
	(iterative_hash_expr): Short-circuit handling of NULL pointer.
	Hash UIDs and versions of SSA names.  Don't special-case built-in
	function declarations.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c.orig	2009-05-09 02:51:44.000000000 -0300
+++ gcc/tree.c	2009-05-10 15:09:58.000000000 -0300
@@ -3626,24 +3626,6 @@ iterative_hash_hashval_t (hashval_t val,
   return val2;
 }
 
-/* Produce good hash value combining PTR and VAL2.  */
-static inline hashval_t
-iterative_hash_pointer (const void *ptr, hashval_t val2)
-{
-  if (sizeof (ptr) == sizeof (hashval_t))
-    return iterative_hash_hashval_t ((size_t) ptr, val2);
-  else
-    {
-      hashval_t a = (hashval_t) (size_t) ptr;
-      /* Avoid warnings about shifting of more than the width of the type on
-         hosts that won't execute this path.  */
-      int zero = 0;
-      hashval_t b = (hashval_t) ((size_t) ptr >> (sizeof (hashval_t) * 8 + zero));
-      mix (a, b, val2);
-      return val2;
-    }
-}
-
 /* Produce good hash value combining VAL and VAL2.  */
 static inline hashval_t
 iterative_hash_host_wide_int (HOST_WIDE_INT val, hashval_t val2)
@@ -5330,7 +5312,7 @@ iterative_hash_expr (const_tree t, hashv
   char tclass;
 
   if (t == NULL_TREE)
-    return iterative_hash_pointer (t, val);
+    return iterative_hash_hashval_t (0, val);
 
   code = TREE_CODE (t);
 
@@ -5364,7 +5346,7 @@ iterative_hash_expr (const_tree t, hashv
 
     case SSA_NAME:
       /* we can just compare by pointer.  */
-      return iterative_hash_pointer (t, val);
+      return iterative_hash_host_wide_int (SSA_NAME_VERSION (t), val);
 
     case TREE_LIST:
       /* A list of expressions, for a CALL_EXPR or as the elements of a
@@ -5388,13 +5370,12 @@ iterative_hash_expr (const_tree t, hashv
 	 __builtin__ form.  Otherwise nodes that compare equal
 	 according to operand_equal_p might get different
 	 hash codes.  */
-      if (DECL_BUILT_IN (t))
+      if (DECL_BUILT_IN (t) && built_in_decls[DECL_FUNCTION_CODE (t)])
 	{
-	  val = iterative_hash_pointer (built_in_decls[DECL_FUNCTION_CODE (t)], 
-				      val);
-	  return val;
+	  t = built_in_decls[DECL_FUNCTION_CODE (t)];
+	  code = TREE_CODE (t);
 	}
-      /* else FALL THROUGH */
+      /* FALL THROUGH */
     default:
       tclass = TREE_CODE_CLASS (code);
 
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]