+2019-07-29 Richard Sandiford <richard.sandiford@arm.com>
+
+ * wide-int.h (generic_wide_int::sext_elt): New function.
+ * inchash.h (hash::add_wide_int): Use it instead of elt.
+
2019-07-29 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* config/arm/arm-builtins.c (acle_builtin_data): Expand VAR1 to
{
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. */
/* Public accessors for the interior of a wide int. */
HOST_WIDE_INT sign_mask () const;
HOST_WIDE_INT elt (unsigned int) const;
+ HOST_WIDE_INT sext_elt (unsigned int) const;
unsigned HOST_WIDE_INT ulow () const;
unsigned HOST_WIDE_INT uhigh () const;
HOST_WIDE_INT slow () const;
return this->get_val ()[i];
}
+/* Like elt, but sign-extend beyond the upper bit, instead of returning
+ the raw encoding. */
+template <typename storage>
+inline HOST_WIDE_INT
+generic_wide_int <storage>::sext_elt (unsigned int i) const
+{
+ HOST_WIDE_INT elt_i = elt (i);
+ if (!is_sign_extended)
+ {
+ unsigned int precision = this->get_precision ();
+ unsigned int lsb = i * HOST_BITS_PER_WIDE_INT;
+ if (precision - lsb < HOST_BITS_PER_WIDE_INT)
+ elt_i = sext_hwi (elt_i, precision - lsb);
+ }
+ return elt_i;
+}
+
template <typename storage>
template <typename T>
inline generic_wide_int <storage> &