hashtab.c (hash_pointer): Remove conditional and avoid unexecuted shift equal to...
authorDavid Edelsohn <dje.gcc@gmail.com>
Mon, 6 May 2013 15:40:54 +0000 (15:40 +0000)
committerDavid Edelsohn <dje@gcc.gnu.org>
Mon, 6 May 2013 15:40:54 +0000 (11:40 -0400)
2013-05-06  David Edelsohn  <dje.gcc@gmail.com>
            Peter Bergner  <bergner@vnet.ibm.com>
            Segher Boessenkool  <segher@kernel.crashing.org>
            Jakub Jelinek  <jakub@redhat.com>

        * hashtab.c (hash_pointer): Remove conditional and avoid
        unexecuted shift equal to wordsize.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
Co-Authored-By: Peter Bergner <bergner@vnet.ibm.com>
Co-Authored-By: Segher Boessenkool <segher@kernel.crashing.org>
From-SVN: r198633

libiberty/ChangeLog
libiberty/hashtab.c

index 1420ad402f3be291793250a4bcef62afff2b3206..a30a363a3f5ac3a40a700d74af00c6ba842654cd 100644 (file)
@@ -1,3 +1,11 @@
+2013-05-06  David Edelsohn  <dje.gcc@gmail.com>
+           Peter Bergner  <bergner@vnet.ibm.com>
+           Segher Boessenkool  <segher@kernel.crashing.org>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * hashtab.c (hash_pointer): Remove conditional and avoid
+       unexecuted shift equal to wordsize.
+
 2013-04-22  Andi Kleen <ak@linux.intel.com>
 
        * hashtab.c (hash_pointer): Move to end of file and reimplement.
index a2fe3ee3bddbff6745024ea3b01df707744574ba..04607ea6a0167bb2c48a7ac847bc5ac968b3a783 100644 (file)
@@ -990,17 +990,8 @@ hash_pointer (const PTR p)
   unsigned a, b, c;
 
   a = b = 0x9e3779b9;
-  if (sizeof (intptr_t) == 4) 
-    {
-      /* Mix as 16bit for now */
-      a += v >> 16;
-      b += v & 0xffff;
-    }
-  else
-    {
-      a += v >> 32;
-      b += v & 0xffffffff;
-    }
+  a += v >> (sizeof (intptr_t) * CHAR_BIT / 2);
+  b += v & (((intptr_t) 1 << (sizeof (intptr_t) * CHAR_BIT / 2)) - 1);
   c = 0x42135234;
   mix (a, b, c);
   return c;