From 22a04bd93ca6031f8765774b9f2ce08eca6111eb Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Thu, 18 Apr 2024 10:13:43 -0700 Subject: [PATCH] Add missing comments --- src/IREquality.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/IREquality.cpp b/src/IREquality.cpp index cfaecda5d029..d6f09c9c970e 100644 --- a/src/IREquality.cpp +++ b/src/IREquality.cpp @@ -55,6 +55,9 @@ struct Comparer { } size_t hash(const IRNode *a, const IRNode *b) { + // A simple hash designed to get enough information into the low bits to + // avoid too many collisions, while being robust to weird things like + // having strided set of Exprs. uintptr_t pa = (uintptr_t)a; uintptr_t pb = (uintptr_t)b; uintptr_t h = (((pa * 17) ^ (pb * 13)) >> 4); @@ -191,6 +194,8 @@ struct Comparer { void cmp(double a, double b) { // Floating point scalars need special handling, due to NaNs. if (std::isnan(a) && std::isnan(b)) { + // Two nans should be considered equal, so leave comparison state + // unchanged. } else if (std::isnan(a)) { result = Order::LessThan; } else if (std::isnan(b)) {