diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-01-18 11:43:02 -0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-25 00:55:18 +0000 |
commit | 388b418e361204b6501cb430abb3ad75694f1a34 (patch) | |
tree | ceb6a74d9d0b3fdc1d6e919bd38ea375021248a4 | |
parent | 34545edc501947a498bc6b1873624a5e307a7b1a (diff) |
QHash: fix iteration of x86 AES hash code for len >= 32
[ChangeLog][QtCore][QHash] Fixed a bug in the qHashBits() function,
which affected the hashing of QByteArray, QString (and their View
classes), QLatin1String and QBitArray, which caused the hash to not
include the final 32 bytes of the data source. As a result, QHash
containers where the initial string was the same had a serious
performance degradation on x86 CPUs with AES support.
Fixes: QTBUG-91739
Change-Id: Icad7c1bad46a449c8e8afffd16cb74dd43440f6c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit b5d480d01d9f8a3cd97c614f579008ac137c9174)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/corelib/tools/qhash.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 0de69ad20a..c6373ee11d 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -564,8 +564,8 @@ static size_t aeshash(const uchar *p, size_t len, size_t seed, size_t seed2) noe // do simplified rounds of 32 bytes: unlike the Go code, we only // scramble twice and we keep 256 bits of state - const auto srcend = src + (len / 32); - while (src < srcend) { + const auto srcend = reinterpret_cast<const __m128i *>(p + len); + while (src + 2 <= srcend) { __m128i data0 = _mm_loadu_si128(src); __m128i data1 = _mm_loadu_si128(src + 1); state0 = _mm_xor_si128(data0, state0); |