]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
adding a comment about further possible improvements
authorWolfgang Bumiller <wry.git@bumiller.com>
Wed, 9 Apr 2014 17:44:05 +0000 (19:44 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Wed, 9 Apr 2014 17:46:19 +0000 (19:46 +0200)
remove unnecessary unsetbit call and commented out/old code

ir.c
liveness.c
liveness.h

diff --git a/ir.c b/ir.c
index 8fe62f99024462516bf0cda6083d898c1607c967..f8a9d28605a610061923decb693d6bf4b22e2492 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -1286,6 +1286,10 @@ bool ir_value_lives(ir_value *self, size_t at)
     return ir_bitlist_getbit(self->life->alive, at);
 }
 
+/* TODO:
+ * Should try adding in ranges whenever a value enters/leaves the living set
+ * instead of adding each instruction separately!
+ */
 GMQCC_INLINE static bool ir_value_life_merge(ir_value *self, size_t s, bool wr)
 {
     bool was_set = ir_bitlist_getbit(self->life->alive, s);
@@ -1297,8 +1301,12 @@ GMQCC_INLINE static bool ir_value_life_merge(ir_value *self, size_t s, bool wr)
          */
         if (ir_bitlist_getbit(self->life->alive, s+1))
             ir_bitlist_setbit  (self->life->dies, s);
-        else /* still need to perform the write to cause an allocation */
+        /* when using dynamically allocated bitfields we still need to cause it
+         * to allocate here.
+         * (but we're not currently)
+        else
             ir_bitlist_unsetbit(self->life->dies, s);
+         */
     }
     else
         ir_bitlist_unsetbit(self->life->dies,  s);
index caa506b17c457bc15fc139e94975d07c15bbd6c9..3a78734d69f5fbc41a2c599e0d1801532a72a29f 100644 (file)
@@ -111,8 +111,6 @@ ir_lifemask_t *ir_lifemask_new(size_t size) {
 void ir_lifemask_delete(ir_lifemask_t *self) {
     ir_bitlist_delete(self->alive);
     ir_bitlist_delete(self->dies);
-    /*if (self->mask)
-        ir_bitlist_delete(self->mask);*/
     mem_d(self);
 }
 
@@ -122,42 +120,14 @@ void ir_lifemask_merge(ir_lifemask_t *self, const ir_lifemask_t *other) {
     if (!other_alive_size)
         return;
 
-    /*
-    ir_bitlist_allocindex(self->alive, other_alive_size-1);
-    ir_bitlist_allocindex(self->dies,  other_alive_size-1);
-    */
-    /*if (self->mask)
-        ir_bitlist_allocindex(self->mask,  other_alive_size-1);*/
-
     for (i = 0; i != other_alive_size; ++i) {
         self->alive->bits[i] |= other->alive->bits[i];
         self->dies->bits[i]  &= ~self->alive->bits[i];
         self->dies->bits[i]  |= ~other->alive->bits[i] & other->dies->bits[i];
-
-        /*if (self->mask)
-            self->mask->bits[i] = self->alive->bits[i] & ~self->dies->bits[i];*/
         self->used = self->alive->bits[i] || self->used;
     }
 }
 
-/*
-void ir_lifemask_setmask(ir_lifemask_t *self) {
-    size_t i;
-    size_t size;
-
-    if (!self->mask)
-        self->mask = ir_bitlist_new();
-
-    size = vec_size(self->alive->bits);
-    if (!size)
-        return;
-
-    ir_bitlist_allocindex(self->mask, size-1);
-    for (i = 0; i != size; ++i)
-        self->mask->bits[i] = self->alive->bits[i] & ~self->dies->bits[i];
-}
-*/
-
 bool ir_lifemask_overlaps(const ir_lifemask_t *a, const ir_lifemask_t *b) {
     size_t i;
     size_t size   = vec_size(a->alive->bits),
@@ -180,59 +150,5 @@ void ir_lifemask_dump(const ir_lifemask_t *self, const char *ind,
     ir_bitlist_dump(self->alive, oprintf);
     oprintf("%s  ", ind);
     ir_bitlist_dump(self->dies, oprintf);
-    /*oprintf("%s  ", ind);
-    ir_bitlist_dump(self->mask, oprintf);*/
     oprintf("%s}\n", ind);
 }
-
-#ifdef LIVETEST
-#include <stdio.h>
-void test_liveness() {
-    con_init();
-    ir_bitlist_t *bl = ir_bitlist_new();
-    ir_bitlist_dump(bl);
-    ir_bitlist_setbit(bl, 1);
-    ir_bitlist_dump(bl);
-    ir_bitlist_setbit(bl, 2);
-    ir_bitlist_dump(bl);
-    ir_bitlist_setrange(bl, 4, 6);
-    ir_bitlist_dump(bl);
-    ir_bitlist_setrange(bl, 8, 9);
-    ir_bitlist_dump(bl);
-    ir_bitlist_setrange(bl, 15, 17);
-    ir_bitlist_dump(bl);
-    ir_bitlist_delete(bl);
-
-    ir_lifemask_t ma, mb;
-    ir_lifemask_init(&ma);
-    ir_lifemask_init(&mb);
-
-    ir_bitlist_setrange(ma.alive, 4, 6);
-    ir_bitlist_setbit(ma.dies,  4);
-    ir_lifemask_dump(&ma);
-
-    ir_bitlist_setrange(mb.alive, 6, 8);
-    ir_bitlist_setbit(mb.dies,  6);
-    ir_lifemask_dump(&mb);
-    con_out(ir_lifemask_overlaps(&ma, &mb) ? "WRONG OVERLAP\n" : "Ok\n");
-
-    ir_bitlist_setrange(mb.alive, 9, 12);
-    ir_bitlist_setbit(mb.dies,  9);
-    ir_lifemask_dump(&mb);
-    con_out(ir_lifemask_overlaps(&ma, &mb) ? "WRONG OVERLAP\n" : "Ok\n");
-
-    ir_bitlist_setrange(mb.alive, 5, 7);
-    ir_bitlist_unsetbit(mb.dies,  6);
-    ir_bitlist_setbit(mb.dies,  5);
-    ir_lifemask_dump(&mb);
-    con_out(ir_lifemask_overlaps(&ma, &mb) ? "overlap\n" : "WRONG ! OVERLAPPING\n");
-
-    ir_lifemask_clear(&ma);
-    ir_lifemask_clear(&mb);
-}
-
-int main() {
-    test_liveness();
-    return 0;
-}
-#endif
index 447d573b4897f89041da99971e0f13f67b658b8f..004bea684f1cfc03287851cfef70da51d146d2a0 100644 (file)
@@ -66,13 +66,11 @@ void ir_lifemask_dump(const ir_lifemask_t *self, const char *ind,
 /* inlined functions */
 GMQCC_INLINE static void ir_bitlist_setbit(ir_bitlist_t *self, size_t bit) {
     size_t index = bit / GMQCC_BL_BITS;
-    /*ir_bitlist_allocindex(self, index);*/
     self->bits[index] |= (1 << (bit % GMQCC_BL_BITS));
 }
 
 GMQCC_INLINE static void ir_bitlist_unsetbit(ir_bitlist_t *self, size_t bit) {
     size_t index = bit / GMQCC_BL_BITS;
-    /*ir_bitlist_allocindex(self, index);*/
     self->bits[index] &= ~(1 << (bit % GMQCC_BL_BITS));
 }