From: Benjamin Kramer Date: Tue, 14 Apr 2020 16:13:49 +0000 (+0200) Subject: [ADT] Mix the bit width into APInt's hash_value X-Git-Tag: llvmorg-12-init~9094 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61ec4cdf6be9f05c65f9cc2e8a1d05320305e9fb;p=platform%2Fupstream%2Fllvm.git [ADT] Mix the bit width into APInt's hash_value Otherwise all zero values from i1 to i64 collide. --- 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 {