From: Philippe Waroquiers Date: Thu, 17 Nov 2011 21:57:21 +0000 (+0000) Subject: The sparse wa maintains the nr of elements in use at level 0. X-Git-Tag: svn/VALGRIND_3_8_0~581 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f403e37982f4e6f09d2b768e0343ade0373688cb;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/coregrind/m_sparsewa.c b/coregrind/m_sparsewa.c index 13bdd185c0..5ad0d5979b 100644 --- a/coregrind/m_sparsewa.c +++ b/coregrind/m_sparsewa.c @@ -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 ) {