From: Julian Seward Date: Thu, 8 Feb 2007 16:25:56 +0000 (+0000) Subject: Specialise VG_(ssort) for 4-word elements. This removes about 80% of X-Git-Tag: svn/VALGRIND_3_3_0~387 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56b4de0b8b1775cacce840477b66f3b20cc9d446;p=thirdparty%2Fvalgrind.git Specialise VG_(ssort) for 4-word elements. This removes about 80% of all calls to VG_(memcpy). Thanks to cachegrind for showing somebody was calling VG_(memcpy) a huge number of times, and to callgrind for finding out who :-) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6577 --- diff --git a/coregrind/m_libcbase.c b/coregrind/m_libcbase.c index cf72be4377..8628feb975 100644 --- a/coregrind/m_libcbase.c +++ b/coregrind/m_libcbase.c @@ -490,10 +490,34 @@ void VG_(ssort)( void* base, SizeT nmemb, SizeT size, #undef ASSIGN #undef COMPAR + } else if ( (4*sizeof(UWord)) == size ) { + /* special-case 4 word-elements. This captures a lot of cases + from symbol table reading/canonicalisaton, because both DiLoc + and DiSym are 4 word structures. */ + HChar* a = base; + HChar v[size]; + + #define ASSIGN(dst, dsti, src, srci) \ + do { UWord* dP = (UWord*)&dst[size*(dsti)]; \ + UWord* sP = (UWord*)&src[size*(srci)]; \ + dP[0] = sP[0]; \ + dP[1] = sP[1]; \ + dP[2] = sP[2]; \ + dP[3] = sP[3]; \ + } while (0) + + #define COMPAR(dst, dsti, src, srci) \ + compar( &dst[size*(dsti)], &src[size*(srci)] ) + + SORT; + + #undef ASSIGN + #undef COMPAR + // General case } else { - char* a = base; - char v[size]; // will be at least 'size' bytes + HChar* a = base; + HChar v[size]; // will be at least 'size' bytes #define ASSIGN(dst, dsti, src, srci) \ VG_(memcpy)( &dst[size*(dsti)], &src[size*(srci)], size );