Add wide_int version of inchash::hash::add_wide_int
authorRichard Sandiford <richard.sandiford@linaro.org>
Sun, 22 Oct 2017 21:04:02 +0000 (21:04 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sun, 22 Oct 2017 21:04:02 +0000 (21:04 +0000)
This patch adds an inchash hasher for wide_int-based types.
It means that hash_tree no longer hashes TREE_INT_CST_EXT_NUNITS,
but that was redundant with hashing the type.

2017-10-22  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* inchash.h (inchash::hash::add_wide_int): New function.
* lto-streamer-out.c (hash_tree): Use it.

From-SVN: r253988

gcc/ChangeLog
gcc/inchash.h
gcc/lto-streamer-out.c

index 2e7eda1..47f93c4 100644 (file)
@@ -1,5 +1,10 @@
 2017-10-22  Richard Sandiford  <richard.sandiford@linaro.org>
 
+       * inchash.h (inchash::hash::add_wide_int): New function.
+       * lto-streamer-out.c (hash_tree): Use it.
+
+2017-10-22  Richard Sandiford  <richard.sandiford@linaro.org>
+
        * inchash.h (inchash::hash::add_wide_int): Rename to...
        (inchash::hash::add_hwi): ...this.
        * ipa-devirt.c (hash_odr_vtable): Update accordingly.
index 29e9e6d..73930c2 100644 (file)
@@ -63,6 +63,15 @@ class hash
     val = iterative_hash_host_wide_int (v, val);
   }
 
+  /* Add wide_int-based value V.  */
+  template<typename T>
+  void add_wide_int (const generic_wide_int<T> &x)
+  {
+    add_int (x.get_len ());
+    for (unsigned i = 0; i < x.get_len (); i++)
+      add_hwi (x.elt (i));
+  }
+
   /* Hash in pointer PTR.  */
   void add_ptr (const void *ptr)
   {
index f9f7677..554f9cc 100644 (file)
@@ -1028,13 +1028,7 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map,
   hstate.commit_flag ();
 
   if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
-    {
-      int i;
-      hstate.add_hwi (TREE_INT_CST_NUNITS (t));
-      hstate.add_hwi (TREE_INT_CST_EXT_NUNITS (t));
-      for (i = 0; i < TREE_INT_CST_NUNITS (t); i++)
-       hstate.add_hwi (TREE_INT_CST_ELT (t, i));
-    }
+    hstate.add_wide_int (wi::to_widest (t));
 
   if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
     {