From 4537b9741014fbd40b9ed5d98a658031997851aa Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 2 Jan 2020 14:57:02 +0000 Subject: [PATCH] aco: don't update demand in add_coupling_code() for loop headers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We don't need to update it since it won't be used later. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_spill.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 576b8e02aea..4179a775388 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -989,8 +989,11 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx) idx++; } - ctx.register_demand[block->index].erase(ctx.register_demand[block->index].begin(), ctx.register_demand[block->index].begin() + idx); - ctx.register_demand[block->index].insert(ctx.register_demand[block->index].begin(), instructions.size(), RegisterDemand()); + if (!ctx.processed[block_idx]) { + assert(!(block->kind & block_kind_loop_header)); + ctx.register_demand[block->index].erase(ctx.register_demand[block->index].begin(), ctx.register_demand[block->index].begin() + idx); + ctx.register_demand[block->index].insert(ctx.register_demand[block->index].begin(), instructions.size(), RegisterDemand()); + } std::vector>::iterator start = std::next(block->instructions.begin(), idx); instructions.insert(instructions.end(), std::move_iterator>::iterator>(start), @@ -1001,6 +1004,8 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx) void process_block(spill_ctx& ctx, unsigned block_idx, Block* block, std::map ¤t_spills, RegisterDemand spilled_registers) { + assert(!ctx.processed[block_idx]); + std::vector> local_next_use_distance; std::vector> instructions; unsigned idx = 0; @@ -1145,7 +1150,6 @@ void process_block(spill_ctx& ctx, unsigned block_idx, Block* block, void spill_block(spill_ctx& ctx, unsigned block_idx) { Block* block = &ctx.program->blocks[block_idx]; - ctx.processed[block_idx] = true; /* determine set of variables which are spilled at the beginning of the block */ RegisterDemand spilled_registers = init_live_in_vars(ctx, block, block_idx); @@ -1182,6 +1186,8 @@ void spill_block(spill_ctx& ctx, unsigned block_idx) else ctx.spills_exit[block_idx].insert(current_spills.begin(), current_spills.end()); + ctx.processed[block_idx] = true; + /* check if the next block leaves the current loop */ if (block->loop_nest_depth == 0 || ctx.program->blocks[block_idx + 1].loop_nest_depth >= block->loop_nest_depth) return; -- 2.30.2