diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-05-16 13:54:56 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-05-20 00:14:40 +0000 |
commit | c780434ba24ff28bc8a19c2a6145c02b703336a7 (patch) | |
tree | e84230a9ac488654aa05908b442729867cc45617 /src | |
parent | 8d19afcc815c62c691293462d4ed0ff25e445cdf (diff) |
qt_is_ascii: improve isAscii a little further (QUrl, QLatin1String)
Turns out that the non-AVX2 code was beating the performance of the AVX2
because the simdTestMask function did a little too much. So just use the
same VPMOVMSKB technique for it.
Change-Id: I0825ff5b5f6f4c85939ffffd152f3b636ab998db
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index bcc94e260a..a4b34263df 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -311,12 +311,19 @@ bool QtPrivate::isAscii(QLatin1String s) Q_DECL_NOTHROW const char *ptr = s.begin(); const char *end = s.end(); -#if defined(__AVX2__) - if (!simdTestMask(ptr, end, 0x80808080)) - return false; -#elif defined(__SSE2__) +#if defined(__SSE2__) // Testing for the high bit can be done efficiently with just PMOVMSKB - while (ptr + 16 < end) { +# if defined(__AVX2__) + while (ptr + 32 <= end) { + __m256i data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(ptr)); + quint32 mask = _mm256_movemask_epi8(data); + if (mask) + return false; + ptr += 32; + } +# endif + + while (ptr + 16 <= end) { __m128i data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr)); quint32 mask = _mm_movemask_epi8(data); if (mask) |