<div dir="ltr">Ping on this discussion - I'm curious about the answer to Eli's question too.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 14, 2020 at 12:31 PM Eli Friedman via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Why does it matter if they collide?  You can't stick two APInts with different widths into a hashtable anyway: the operator== asserts.<br>
<br>
-Eli<br>
<br>
-----Original Message-----<br>
From: llvm-commits <<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.llvm.org</a>> On Behalf Of Benjamin Kramer via llvm-commits<br>
Sent: Tuesday, April 14, 2020 9:19 AM<br>
To: <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
Subject: [EXT] [llvm] 61ec4cd - [ADT] Mix the bit width into APInt's hash_value<br>
<br>
<br>
Author: Benjamin Kramer<br>
Date: 2020-04-14T18:16:15+02:00<br>
New Revision: 61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb.diff</a><br>
<br>
LOG: [ADT] Mix the bit width into APInt's hash_value<br>
<br>
Otherwise all zero values from i1 to i64 collide.<br>
<br>
Added:<br>
<br>
<br>
Modified:<br>
    llvm/lib/Support/APInt.cpp<br>
<br>
Removed:<br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp<br>
index faef9a31a0ed..4a591efb141a 100644<br>
--- a/llvm/lib/Support/APInt.cpp<br>
+++ b/llvm/lib/Support/APInt.cpp<br>
@@ -548,9 +548,11 @@ unsigned APInt::getBitsNeeded(StringRef str, uint8_t radix) {<br>
<br>
 hash_code llvm::hash_value(const APInt &Arg) {<br>
   if (Arg.isSingleWord())<br>
-    return hash_combine(Arg.U.VAL);<br>
+    return hash_combine(Arg.BitWidth, Arg.U.VAL);<br>
<br>
-  return hash_combine_range(Arg.U.pVal, Arg.U.pVal + Arg.getNumWords());<br>
+  return hash_combine(<br>
+      Arg.BitWidth,<br>
+      hash_combine_range(Arg.U.pVal, Arg.U.pVal + Arg.getNumWords()));<br>
 }<br>
<br>
 bool APInt::isSplat(unsigned SplatSizeInBits) const {<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>