From e019c92c2a9606105c2637bf6646d23d7f5d25ff Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Mon, 27 Feb 2012 11:00:17 +0000 Subject: [PATCH] Help the compiler to eliminate some dead code when hashing an array of T where sizeof (T) is a multiple of 4. llvm-svn: 151523 --- include/llvm/ADT/Hashing.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/llvm/ADT/Hashing.h b/include/llvm/ADT/Hashing.h index 27c411e3223..682dc223e22 100644 --- a/include/llvm/ADT/Hashing.h +++ b/include/llvm/ADT/Hashing.h @@ -142,6 +142,7 @@ private: } // Add a range of bytes from I to E. + template void addBytes(const char *I, const char *E) { uint32_t Data; // Note that aliasing rules forbid us from dereferencing @@ -154,7 +155,7 @@ private: std::memcpy(&Data, I, sizeof Data); mix(Data); } - if (I != E) { + if (!ElementsHaveEvenLength && I != E) { Data = 0; std::memcpy(&Data, I, E - I); mix(Data); @@ -164,8 +165,9 @@ private: // Add a range of bits from I to E. template void addBits(const T *I, const T *E) { - addBytes(reinterpret_cast(I), - reinterpret_cast(E)); + addBytes( + reinterpret_cast(I), + reinterpret_cast(E)); } };