On Tue, Apr 18, 2023 at 12:50:58PM +0200, Aldy Hernandez wrote:
> --- a/gcc/value-range.cc
> +++ b/gcc/value-range.cc
> @@ -232,6 +232,58 @@ vrange::dump (FILE *file) const
> pp_flush (&buffer);
> }
>
> +namespace inchash
> +{
> +
> +void
> +add_vrange (const vrange &v, inchash::hash &hstate,
> + unsigned int)
> +{
> + if (v.undefined_p ())
> + {
> + hstate.add_int (VR_UNDEFINED);
> + return;
> + }
> + // Types are ignored throughout to inhibit two ranges being equal
> + // but having different hash values. This can happen when two
> + // ranges are equal and their types are different (but
> + // types_compatible_p is true).
> + if (is_a <irange> (v))
> + {
> + const irange &r = as_a <irange> (v);
> + if (r.varying_p ())
> + hstate.add_int (VR_VARYING);
> + else
> + hstate.add_int (VR_RANGE);
Shouldn't this also
hstate.add_int (r.num_pairs ());
?
Or is that unnecessary because different number of add_wide_int
calls will likely result in different hashes then?
Otherwise LGTM.
> + for (unsigned i = 0; i < r.num_pairs (); ++i)
> + {
> + hstate.add_wide_int (r.lower_bound (i));
> + hstate.add_wide_int (r.upper_bound (i));
> + }
> + hstate.add_wide_int (r.get_nonzero_bits ());
> + return;
> + }
Jakub