diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2020-08-04 21:37:01 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2020-08-17 17:21:02 -0700 |
commit | 46214c96af6c9be337ce0a67fbaed1651815e7bd (patch) | |
tree | ff2ae88a78db52b724bd0344a204fc7c0a858417 | |
parent | 11740acbca1f7de9598844244470ac48ed5c5f36 (diff) |
QtPrivate::isLatin1: fix SSE2 non-SSE4.1 code
The implementation was broken. The "high" in PUNPCKHBW's "unpack high
data" means the high 64-bit of the 128-bit, not the high byte of a 16-
bit word. This never worked. It always passed for me because I don't
build non-SSE4.2 code (too old, no longer relevant).
So just use the working version of simdTestMask.
Change-Id: I35a1b4d0a19a43149daefffd16284542f0de3fa3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 9422b5ebc3592f4687650a84131e736219308b9f)
-rw-r--r-- | src/corelib/tools/qstring.cpp | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index a04f48ef8e..601e5ba114 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -560,31 +560,12 @@ bool QtPrivate::isLatin1(QStringView s) Q_DECL_NOTHROW const QChar *ptr = s.begin(); const QChar *end = s.end(); -#if defined(__SSE4_1__) +#ifdef __SSE2__ const char *ptr8 = reinterpret_cast<const char *>(ptr); const char *end8 = reinterpret_cast<const char *>(end); if (!simdTestMask(ptr8, end8, 0xff00ff00)) return false; ptr = reinterpret_cast<const QChar *>(ptr8); -#elif defined(__SSE2__) - // Testing if every other byte is non-zero can be done efficiently by - // using PUNPCKHBW (unpack high order bytes) and comparing that to zero. - while (ptr + 32 < end) { - __m128i data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr)); - __m128i data2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr + 16)); - __m128i high = _mm_unpackhi_epi8(data1, data2); - __m128i comparison = _mm_cmpeq_epi16(high, _mm_setzero_si128()); - if (_mm_movemask_epi8(comparison)) - return false; - ptr += 16; - } - if (ptr + 16 < end) { - __m128i data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr)); - __m128i high = _mm_unpackhi_epi8(data1, data1); - __m128i comparison = _mm_cmpeq_epi16(high, _mm_setzero_si128()); - if (_mm_movemask_epi8(comparison)) - return false; - } #endif while (ptr != end) { |