On 4/18/23 12:59, Jakub Jelinek wrote:
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?
That was my thinking, and we could save one write.
I can add the num_pairs() if you prefer. I don't have a strong opinion.
Aldy