From ad2cc7bddc094639508e4942310dbd2896be7774 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 3 Dec 2015 11:49:51 -0500 Subject: [PATCH] freedreno/ir3: don't reuse a0.x across blocks It causes confusion in sched if we need to split_addr() since otherwise we wouldn't easily know which block the new addr instr will be scheduled in. So just side-step the whole situation. Signed-off-by: Rob Clark --- .../drivers/freedreno/ir3/ir3_compiler_nir.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c index eb24120..4278b0b 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c @@ -236,8 +236,6 @@ compile_init(struct ir3_compiler *compiler, _mesa_hash_pointer, _mesa_key_pointer_equal); ctx->var_ht = _mesa_hash_table_create(ctx, _mesa_hash_pointer, _mesa_key_pointer_equal); - ctx->addr_ht = _mesa_hash_table_create(ctx, - _mesa_hash_pointer, _mesa_key_pointer_equal); ctx->block_ht = _mesa_hash_table_create(ctx, _mesa_hash_pointer, _mesa_key_pointer_equal); @@ -583,12 +581,17 @@ static struct ir3_instruction * get_addr(struct ir3_compile *ctx, struct ir3_instruction *src) { struct ir3_instruction *addr; - struct hash_entry *entry; - entry = _mesa_hash_table_search(ctx->addr_ht, src); - if (entry) - return entry->data; - /* TODO do we need to cache per block? */ + if (!ctx->addr_ht) { + ctx->addr_ht = _mesa_hash_table_create(ctx, + _mesa_hash_pointer, _mesa_key_pointer_equal); + } else { + struct hash_entry *entry; + entry = _mesa_hash_table_search(ctx->addr_ht, src); + if (entry) + return entry->data; + } + addr = create_addr(ctx->block, src); _mesa_hash_table_insert(ctx->addr_ht, src, addr); @@ -1980,6 +1983,10 @@ emit_block(struct ir3_compile *ctx, nir_block *nblock) ctx->block = block; list_addtail(&block->node, &ctx->ir->block_list); + /* re-emit addr register in each block if needed: */ + _mesa_hash_table_destroy(ctx->addr_ht, NULL); + ctx->addr_ht = NULL; + nir_foreach_instr(nblock, instr) { emit_instr(ctx, instr); if (ctx->error) -- 2.7.4