diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-18 15:29:27 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-03-22 14:51:44 (GMT) |
commit | dcb2ea1344a08c397dbdd125c2787d33ebfd4fc7 (patch) | |
tree | ae067a078d0831c8e9f26335ec0ad4cb9e135152 /tests/benchmarks | |
parent | 68ad53407d8feefbfb2a1282d69da4ae9007766b (diff) | |
download | Qt-dcb2ea1344a08c397dbdd125c2787d33ebfd4fc7.zip Qt-dcb2ea1344a08c397dbdd125c2787d33ebfd4fc7.tar.gz Qt-dcb2ea1344a08c397dbdd125c2787d33ebfd4fc7.tar.bz2 |
Add the SSE2 code we have in Qt 4.7 to the benchmark
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/corelib/tools/qstring/main.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index f957eee..5513724 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -1449,6 +1449,31 @@ void fromLatin1_regular(QChar *dst, const char *str, int size) *dst++ = (uchar)*str++; } +void fromLatin1_sse2_qt47(QChar *dst, const char *str, int size) +{ + if (size >= 16) { + int chunkCount = size >> 4; // divided by 16 + const __m128i nullMask = _mm_set1_epi32(0); + for (int i = 0; i < chunkCount; ++i) { + const __m128i chunk = _mm_loadu_si128((__m128i*)str); // load + str += 16; + + // unpack the first 8 bytes, padding with zeros + const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask); + _mm_storeu_si128((__m128i*)dst, firstHalf); // store + dst += 8; + + // unpack the last 8 bytes, padding with zeros + const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask); + _mm_storeu_si128((__m128i*)dst, secondHalf); // store + dst += 8; + } + size = size % 16; + } + while (size--) + *dst++ = (uchar)*str++; +} + typedef void (* FromLatin1Function)(QChar *, const char *, int); Q_DECLARE_METATYPE(FromLatin1Function) @@ -1456,6 +1481,7 @@ void tst_QString::fromLatin1Alternatives_data() const { QTest::addColumn<FromLatin1Function>("function"); QTest::newRow("regular") << &fromLatin1_regular; + QTest::newRow("sse2-qt4.7") << &fromLatin1_sse2_qt47; } static void fromLatin1Alternatives_internal(FromLatin1Function function, bool doVerify) |