]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
The sparse wa maintains the nr of elements in use at level 0.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 17 Nov 2011 21:57:21 +0000 (21:57 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 17 Nov 2011 21:57:21 +0000 (21:57 +0000)
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

coregrind/m_sparsewa.c

index 13bdd185c05780e57edfe43fda8a6dabbe768a24..5ad0d5979bd3f8aaaed8d52d1cc15b518f3aaab6 100644 (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 )
 {