diff options
author | sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2015-02-04 17:52:42 +0000 |
---|---|---|
committer | sewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9> | 2015-02-04 17:52:42 +0000 |
commit | 11e20f70b6da76415ca57b8fc75a4ac8d6411e53 (patch) | |
tree | c97a6a406a11b7490f118db9c2ffa923814f161d /shared | |
parent | 7f394610654a56807c85533398544411af9c4e11 (diff) | |
download | valgrind-11e20f70b6da76415ca57b8fc75a4ac8d6411e53.tar.gz |
Vectorise the memcmp template implementation. For scenarios requiring
a lot of memcmp-ing (firefox reftests) this is measurably faster.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14901 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'shared')
-rw-r--r-- | shared/vg_replace_strmem.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/shared/vg_replace_strmem.c b/shared/vg_replace_strmem.c index 5203306bd..ab1b1a85e 100644 --- a/shared/vg_replace_strmem.c +++ b/shared/vg_replace_strmem.c @@ -959,18 +959,33 @@ static inline void my_exit ( int x ) int VG_REPLACE_FUNCTION_EZU(20190,soname,fnname) \ ( const void *s1V, const void *s2V, SizeT n ) \ { \ - int res; \ - UChar a0; \ - UChar b0; \ - const UChar* s1 = s1V; \ - const UChar* s2 = s2V; \ + const Addr WS = sizeof(UWord); /* 8 or 4 */ \ + const Addr WM = WS - 1; /* 7 or 3 */ \ + Addr s1A = (Addr)s1V; \ + Addr s2A = (Addr)s2V; \ + \ + if (((s1A | s2A) & WM) == 0) { \ + /* Both areas are word aligned. Skip over the */ \ + /* equal prefix as fast as possible. */ \ + while (n >= WS) { \ + UWord w1 = *(UWord*)s1A; \ + UWord w2 = *(UWord*)s2A; \ + if (w1 != w2) break; \ + s1A += WS; \ + s2A += WS; \ + n -= WS; \ + } \ + } \ + \ + const UChar* s1 = (const UChar*) s1A; \ + const UChar* s2 = (const UChar*) s2A; \ \ while (n != 0) { \ - a0 = s1[0]; \ - b0 = s2[0]; \ + UChar a0 = s1[0]; \ + UChar b0 = s2[0]; \ s1 += 1; \ s2 += 1; \ - res = ((int)a0) - ((int)b0); \ + int res = ((int)a0) - ((int)b0); \ if (res != 0) \ return res; \ n -= 1; \ |