-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
5 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
abadams
Author
Member
|
||
// unchanged. | ||
} else if (std::isnan(a)) { | ||
result = Order::LessThan; | ||
} else if (std::isnan(b)) { | ||
|
Maybe it doesn't matter here, but IIRC IEEE754 says that nans aren't equal to anything, including other nans