summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-08-04 21:37:01 -0700
committerThiago Macieira <thiago.macieira@intel.com>2020-08-05 21:51:24 -0700
commit9422b5ebc3592f4687650a84131e736219308b9f (patch)
tree4ac472419a2df84aa92f190088721e74f4d52ef9 /src/corelib
parent60aa0d086886aea58d6b7a09484645ad1d92a220 (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. Pick-to: 5.15 5.12 Change-Id: I35a1b4d0a19a43149daefffd16284542f0de3fa3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qstring.cpp21
1 files changed, 1 insertions, 20 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index b63b980e72..82cdeec1a3 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -564,31 +564,12 @@ bool QtPrivate::isLatin1(QStringView s) noexcept
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) {