From 5d5bb9bc26bbd714ef81a7eb91e77e312582ccdc Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 29 Jul 2019 18:50:25 +0000 Subject: Fix inchash handling of wide_ints (PR91242) inchash::hash::add_wide_int operated directly on the raw encoding of the wide_int, including any redundant upper bits. The problem with that is that the upper bits are only defined for some wide-int storage types (including wide_int itself). wi::to_wide(tree) instead returns a value that is extended according to the signedness of the type (so that wi::to_widest can use the same encoding) while rtxes have the awkward special case of BI, which can be zero-extended rather than sign-extended. In the PR, we computed a hash for a "normal" sign-extended wide_int while the existing entries hashed wi::to_wide(tree). This gives different results for unsigned types that have the top bit set. The patch fixes that by hashing the canonical sign-extended form even if the raw encoding happens to be different. 2019-07-29 Richard Sandiford gcc/ * wide-int.h (generic_wide_int::sext_elt): New function. * inchash.h (hash::add_wide_int): Use it instead of elt. From-SVN: r273881 --- gcc/inchash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/inchash.h') diff --git a/gcc/inchash.h b/gcc/inchash.h index f61e631..56588d2 100644 --- a/gcc/inchash.h +++ b/gcc/inchash.h @@ -85,7 +85,7 @@ class hash { add_int (x.get_len ()); for (unsigned i = 0; i < x.get_len (); i++) - add_hwi (x.elt (i)); + add_hwi (x.sext_elt (i)); } /* Hash in pointer PTR. */ -- cgit v1.1