The sparse wa maintains the nr of elements in use at level 0.

So, replace the code which counts the nr of bits in the level0
bitmap by just returning the nr of elements in use.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12272
This commit is contained in:
Philippe Waroquiers 2011-11-17 21:57:21 +00:00
parent 246525e3d9
commit f403e37982

View File

@ -435,33 +435,21 @@ Bool VG_(delFromSWA) ( SparseWA* swa,
static UWord swa_sizeSWA_wrk ( void* nd )
{
Int i;
UWord sum = 0;
if (*(UWord*)nd == LevelN_MAGIC) {
UWord sum = 0;
LevelN* levelN = (LevelN*)nd;
for (i = 0; i < 256; i++) {
if (levelN->child[i]) {
sum += swa_sizeSWA_wrk( levelN->child[i] );
}
}
}
return sum;
} else {
Level0* level0;
vg_assert(*(UWord*)nd == Level0_MAGIC);
level0 = (Level0*)nd;
for (i = 0; i < 256/8; i += 2) {
UWord x = level0->inUse[i+0]; /* assume zero-extend */
UWord y = level0->inUse[i+1]; /* assume zero-extend */
/* do 'sum += popcount(x) + popcount(y)' for byte-sized x, y */
/* unroll the loop twice so as to expose more ILP */
x = (x & 0x55) + ((x >> 1) & 0x55);
y = (y & 0x55) + ((y >> 1) & 0x55);
x = (x & 0x33) + ((x >> 2) & 0x33);
y = (y & 0x33) + ((y >> 2) & 0x33);
x = (x & 0x0F) + ((x >> 4) & 0x0F);
y = (y & 0x0F) + ((y >> 4) & 0x0F);
sum += x + y;
}
return level0->nInUse;
}
return sum;
}
UWord VG_(sizeSWA) ( SparseWA* swa )
{