summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-08-18 10:26:36 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-08-24 10:36:40 (GMT)
commit6cea948a0ceabe5493bb2a75f236b008b47fd71e (patch)
treebc34de5aa33fc63ed00bd3059f498ed96eb380e1 /tests/benchmarks
parent6f913f94c6b6aaf8514bc62d4f9939ac44e211fb (diff)
downloadQt-6cea948a0ceabe5493bb2a75f236b008b47fd71e.zip
Qt-6cea948a0ceabe5493bb2a75f236b008b47fd71e.tar.gz
Qt-6cea948a0ceabe5493bb2a75f236b008b47fd71e.tar.bz2
Optimise the tail comparison of ucstrncmp
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/tools/qstring/main.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp
index 608e2bc..0b7254f 100644
--- a/tests/benchmarks/corelib/tools/qstring/main.cpp
+++ b/tests/benchmarks/corelib/tools/qstring/main.cpp
@@ -881,6 +881,40 @@ static int ucstrncmp_intwise(const ushort *a, const ushort *b, int len)
}
#ifdef __SSE2__
+static inline int ucstrncmp_short_tail(const ushort *p1, const ushort *p2, int len)
+{
+ if (len) {
+ if (*p1 != *p2)
+ return *p1 - *p2;
+ if (--len) {
+ if (p1[1] != p2[1])
+ return p1[1] - p2[1];
+ if (--len) {
+ if (p1[2] != p2[2])
+ return p1[2] - p2[2];
+ if (--len) {
+ if (p1[3] != p2[3])
+ return p1[3] - p2[3];
+ if (--len) {
+ if (p1[4] != p2[4])
+ return p1[4] - p2[4];
+ if (--len) {
+ if (p1[5] != p2[5])
+ return p1[5] - p2[5];
+ if (--len) {
+ if (p1[6] != p2[6])
+ return p1[6] - p2[6];
+ return p1[7] - p2[7];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
+
static inline int bsf_nonzero(register long val)
{
int result;
@@ -911,7 +945,7 @@ static __attribute__((optimize("no-unroll-loops"))) int ucstrncmp_sse2(const ush
counter += 8;
len -= 8;
}
- return ucstrncmp_shortwise(a + counter, b + counter, len);
+ return ucstrncmp_short_tail(a + counter, b + counter, len);
}
static __attribute__((optimize("no-unroll-loops"))) int ucstrncmp_sse2_aligning(const ushort *a, const ushort *b, int len)
@@ -950,7 +984,7 @@ static __attribute__((optimize("no-unroll-loops"))) int ucstrncmp_sse2_aligning(
counter += 8;
len -= 8;
}
- return ucstrncmp_shortwise(a + counter, b + counter, len);
+ return ucstrncmp_short_tail(a + counter, b + counter, len);
}
#endif