pan/bi: Shrink live array to 8-bits

We only actually use 4-bits, so we could shrink again. But this by
itself means 1/2 the memory usage for liveness analysis and 1/2 the
copying/alloc/free.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11936>
This commit is contained in:
Alyssa Rosenzweig 2021-07-16 19:17:53 -04:00 committed by Marge Bot
parent bbf2ef6b4a
commit 7de5293b89
4 changed files with 13 additions and 15 deletions

View file

@ -32,7 +32,7 @@
* returns whether progress was made. */
void
bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)
bi_liveness_ins_update(uint8_t *live, bi_instr *ins, unsigned max)
{
/* live_in[s] = GEN[s] + (live_out[s] - KILL[s]) */
@ -46,7 +46,7 @@ bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)
bi_foreach_src(ins, src) {
unsigned count = bi_count_read_registers(ins, src);
unsigned rmask = BITFIELD_MASK(count);
uint16_t mask = (rmask << ins->src[src].offset);
uint8_t mask = (rmask << ins->src[src].offset);
unsigned node = bi_get_node(ins->src[src]);
if (node < max)
@ -65,8 +65,8 @@ liveness_block_update(bi_block *blk, unsigned temp_count)
blk->live_out[i] |= succ->live_in[i];
}
uint16_t *live = ralloc_array(blk, uint16_t, temp_count);
memcpy(live, blk->live_out, temp_count * sizeof(uint16_t));
uint8_t *live = ralloc_array(blk, uint8_t, temp_count);
memcpy(live, blk->live_out, temp_count);
bi_foreach_instr_in_block_rev(blk, ins)
bi_liveness_ins_update(live, (bi_instr *) ins, temp_count);
@ -112,8 +112,8 @@ bi_compute_liveness(bi_context *ctx)
if (block->live_out)
ralloc_free(block->live_out);
block->live_in = rzalloc_array(block, uint16_t, temp_count);
block->live_out = rzalloc_array(block, uint16_t, temp_count);
block->live_in = rzalloc_array(block, uint8_t, temp_count);
block->live_out = rzalloc_array(block, uint8_t, temp_count);
}
/* Initialize the work list with the exit block */

View file

@ -36,7 +36,7 @@ bi_opt_dead_code_eliminate(bi_context *ctx)
bi_compute_liveness(ctx);
bi_foreach_block_rev(ctx, block) {
uint16_t *live = rzalloc_array(block, uint16_t, temp_count);
uint8_t *live = rzalloc_array(block, uint8_t, temp_count);
bi_foreach_successor(block, succ) {
for (unsigned i = 0; i < temp_count; ++i)

View file

@ -207,7 +207,7 @@ bi_make_affinity(uint64_t clobber, unsigned count, bool split_file)
}
static void
bi_mark_interference(bi_block *block, struct lcra_state *l, uint16_t *live, uint64_t preload_live, unsigned node_count, bool is_blend, bool split_file)
bi_mark_interference(bi_block *block, struct lcra_state *l, uint8_t *live, uint64_t preload_live, unsigned node_count, bool is_blend, bool split_file)
{
bi_foreach_instr_in_block_rev(block, ins) {
/* Mark all registers live after the instruction as
@ -265,7 +265,7 @@ bi_compute_interference(bi_context *ctx, struct lcra_state *l, bool full_regs)
bi_postra_liveness(ctx);
bi_foreach_block_rev(ctx, blk) {
uint16_t *live = mem_dup(blk->live_out, node_count * sizeof(uint16_t));
uint8_t *live = mem_dup(blk->live_out, node_count);
bi_mark_interference(blk, l, live, blk->reg_live_out,
node_count, ctx->inputs->is_blend, !full_regs);

View file

@ -537,11 +537,9 @@ typedef struct bi_block {
struct set *predecessors;
bool unconditional_jumps;
/* In liveness analysis, these are live masks (per-component) for
* indices for the block. Scalar compilers have the luxury of using
* simple bit fields, but for us, liveness is a vector idea. */
uint16_t *live_in;
uint16_t *live_out;
/* Per 32-bit word live masks for the block indexed by node */
uint8_t *live_in;
uint8_t *live_out;
/* If true, uses clauses; if false, uses instructions */
bool scheduled;
@ -842,7 +840,7 @@ int bi_test_packing_formats(void);
/* Liveness */
void bi_compute_liveness(bi_context *ctx);
void bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max);
void bi_liveness_ins_update(uint8_t *live, bi_instr *ins, unsigned max);
void bi_invalidate_liveness(bi_context *ctx);
void bi_postra_liveness(bi_context *ctx);