|
From: <sv...@va...> - 2008-02-08 00:29:32
|
Author: sewardj
Date: 2008-02-08 00:29:35 +0000 (Fri, 08 Feb 2008)
New Revision: 7381
Log:
Vectorise VG_(memset): it's increasingly popular, and poking bytes
into memory one at a time really isn't where it's at.
Modified:
branches/DATASYMS/coregrind/m_libcbase.c
Modified: branches/DATASYMS/coregrind/m_libcbase.c
===================================================================
--- branches/DATASYMS/coregrind/m_libcbase.c 2008-02-07 12:31:07 UTC (rev 7380)
+++ branches/DATASYMS/coregrind/m_libcbase.c 2008-02-08 00:29:35 UTC (rev 7381)
@@ -519,23 +519,39 @@
return dest;
}
-void* VG_(memset) ( void *dest, Int c, SizeT sz )
+void* VG_(memset) ( void *destV, Int c, SizeT sz )
{
- Char *d = (Char *)dest;
+ Int c4;
+ Char* d = (Char*)destV;
+ while ((!VG_IS_4_ALIGNED(d)) && sz >= 1) {
+ d[0] = c;
+ d++;
+ sz--;
+ }
+ if (sz == 0)
+ return destV;
+ c4 = c & 0xFF;
+ c4 |= (c4 << 8);
+ c4 |= (c4 << 16);
+ while (sz >= 16) {
+ ((Int*)d)[0] = c4;
+ ((Int*)d)[1] = c4;
+ ((Int*)d)[2] = c4;
+ ((Int*)d)[3] = c4;
+ d += 16;
+ sz -= 16;
+ }
while (sz >= 4) {
- d[0] = c;
- d[1] = c;
- d[2] = c;
- d[3] = c;
+ ((Int*)d)[0] = c4;
d += 4;
sz -= 4;
}
- while (sz > 0) {
+ while (sz >= 1) {
d[0] = c;
d++;
sz--;
}
- return dest;
+ return destV;
}
Int VG_(memcmp) ( const void* s1, const void* s2, SizeT n )
|