summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2011-03-19 15:40:23 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2011-03-22 14:51:59 (GMT)
commit543aa4bf21b169a48e5c3164ddd453e99e83d4ee (patch)
treebbe325b4c766198774db7a813bd4eb2eb078538a /tests/benchmarks
parentadbb2aed4e2fcbc506e3d497001530e1a177aafc (diff)
downloadQt-543aa4bf21b169a48e5c3164ddd453e99e83d4ee.zip
Qt-543aa4bf21b169a48e5c3164ddd453e99e83d4ee.tar.gz
Qt-543aa4bf21b169a48e5c3164ddd453e99e83d4ee.tar.bz2
Improve the code and avoid unnecessary stores
If there's an UTF-8 high byte in the first 8 bytes, don't try to save the latter 8 characters
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/tools/qstring/main.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp
index e05915d..39c9739 100644
--- a/tests/benchmarks/corelib/tools/qstring/main.cpp
+++ b/tests/benchmarks/corelib/tools/qstring/main.cpp
@@ -2068,19 +2068,21 @@ int fromUtf8_sse2_optimised_for_ascii(ushort *qch, const char *chars, int len)
const __m128i nullMask = _mm_set1_epi32(0);
while (counter < len) {
const __m128i chunk = _mm_loadu_si128((__m128i*)(chars + counter)); // load
+ ushort highbytes = _mm_movemask_epi8(chunk);
// unpack the first 8 bytes, padding with zeros
const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask);
_mm_storeu_si128((__m128i*)(dst + counter), firstHalf); // store
- // unpack the last 8 bytes, padding with zeros
- const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask);
- _mm_storeu_si128((__m128i*)(dst + counter + 8), secondHalf); // store
+ if (!uchar(highbytes)) {
+ // unpack the last 8 bytes, padding with zeros
+ const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask);
+ _mm_storeu_si128((__m128i*)(dst + counter + 8), secondHalf); // store
- ushort highbytes = _mm_movemask_epi8(chunk);
- if (!highbytes) {
- counter += 16;
- continue;
+ if (!highbytes) {
+ counter += 16;
+ continue;
+ }
}
// UTF-8 character found