From: Wolfgang Bumiller Date: Wed, 9 Apr 2014 17:44:05 +0000 (+0200) Subject: adding a comment about further possible improvements X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9de59d26f69be80d432d0fe4ea654d2a23f6563f;p=xonotic%2Fgmqcc.git adding a comment about further possible improvements remove unnecessary unsetbit call and commented out/old code --- diff --git a/ir.c b/ir.c index 8fe62f9..f8a9d28 100644 --- 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); diff --git a/liveness.c b/liveness.c index caa506b..3a78734 100644 --- a/liveness.c +++ b/liveness.c @@ -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 -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 diff --git a/liveness.h b/liveness.h index 447d573..004bea6 100644 --- a/liveness.h +++ b/liveness.h @@ -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)); }