From cae115d6d4552a29efb4ea94363d63bde985b4d8 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sun, 22 Oct 2017 21:04:02 +0000 Subject: [PATCH] Add wide_int version of inchash::hash::add_wide_int 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 gcc/ * inchash.h (inchash::hash::add_wide_int): New function. * lto-streamer-out.c (hash_tree): Use it. From-SVN: r253988 --- gcc/ChangeLog | 5 +++++ gcc/inchash.h | 9 +++++++++ gcc/lto-streamer-out.c | 8 +------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e7eda1..47f93c4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-10-22 Richard Sandiford + * inchash.h (inchash::hash::add_wide_int): New function. + * lto-streamer-out.c (hash_tree): Use it. + +2017-10-22 Richard Sandiford + * inchash.h (inchash::hash::add_wide_int): Rename to... (inchash::hash::add_hwi): ...this. * ipa-devirt.c (hash_odr_vtable): Update accordingly. diff --git a/gcc/inchash.h b/gcc/inchash.h index 29e9e6d..73930c2 100644 --- a/gcc/inchash.h +++ b/gcc/inchash.h @@ -63,6 +63,15 @@ class hash val = iterative_hash_host_wide_int (v, val); } + /* Add wide_int-based value V. */ + template + void add_wide_int (const generic_wide_int &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) { diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index f9f7677..554f9cc 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -1028,13 +1028,7 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map *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)) { -- 2.7.4