From d8ad0812c7fdc2684ce7f09cc13b69f567e82031 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Aug 2010 21:14:00 +0200 Subject: Add a benchmark for SSE2 comparison. This function uses unaligned loads. I'll try to write one with aligned loads later. --- tests/benchmarks/corelib/tools/qstring/main.cpp | 27 ++++++++++++++++++++++ tests/benchmarks/corelib/tools/qstring/qstring.pro | 1 + 2 files changed, 28 insertions(+) diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index 9eb6294..5210034 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -219,6 +219,27 @@ static bool equals2_intwise(ushort *p1, ushort *p2, int length) return true; } +#ifdef __SSE2__ +static bool equals2_sse2(ushort *p1, ushort *p2, int len) +{ + if (len > 8) { + while (len > 8) { + __m128i q1 = _mm_loadu_si128((__m128i *)p1); + __m128i q2 = _mm_loadu_si128((__m128i *)p2); + __m128i cmp = _mm_cmpeq_epi16(q1, q2); + if (ushort(_mm_movemask_epi8(cmp)) != 0xffff) + return false; + + len -= 8; + p1 += 8; + p2 += 8; + } + } + + return equals2_shortwise(p1, p2, len); +} +#endif + void tst_QString::equals2_data() const { QTest::addColumn("algorithm"); @@ -227,6 +248,9 @@ void tst_QString::equals2_data() const QTest::newRow("bytewise") << 1; QTest::newRow("shortwise") << 2; QTest::newRow("intwise") << 3; +#ifdef __SSE2__ + QTest::newRow("sse2") << 4; +#endif } void tst_QString::equals2() const @@ -274,6 +298,9 @@ void tst_QString::equals2() const equals2_bytewise, // 1 equals2_shortwise, // 1 equals2_intwise, // 3 +#ifdef __SSE2__ + equals2_sse2, // 4 +#endif 0 }; diff --git a/tests/benchmarks/corelib/tools/qstring/qstring.pro b/tests/benchmarks/corelib/tools/qstring/qstring.pro index fa4310e..388e3c2 100644 --- a/tests/benchmarks/corelib/tools/qstring/qstring.pro +++ b/tests/benchmarks/corelib/tools/qstring/qstring.pro @@ -14,3 +14,4 @@ wince*:{ DEFINES += SRCDIR=\\\"$$PWD/\\\" } +sse2:QMAKE_CXXFLAGS += -msse2 -- cgit v0.12