From 61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 14 Apr 2020 18:13:49 +0200 Subject: [PATCH] [ADT] Mix the bit width into APInt's hash_value Otherwise all zero values from i1 to i64 collide. --- llvm/lib/Support/APInt.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index faef9a3..4a591ef 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -548,9 +548,11 @@ unsigned APInt::getBitsNeeded(StringRef str, uint8_t radix) { hash_code llvm::hash_value(const APInt &Arg) { if (Arg.isSingleWord()) - return hash_combine(Arg.U.VAL); + return hash_combine(Arg.BitWidth, Arg.U.VAL); - return hash_combine_range(Arg.U.pVal, Arg.U.pVal + Arg.getNumWords()); + return hash_combine( + Arg.BitWidth, + hash_combine_range(Arg.U.pVal, Arg.U.pVal + Arg.getNumWords())); } bool APInt::isSplat(unsigned SplatSizeInBits) const { -- 2.7.4