From 387b315ea047779db4a0657c1280bc3bd5531eaa Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 10 Jul 2021 13:59:42 +0200 Subject: [PATCH] aco/spill: Avoid copying next_use maps more often than needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_spill.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 646b492..fcb0eaf 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -359,10 +359,11 @@ local_next_uses(spill_ctx& ctx, Block* block) { std::vector> local_next_uses(block->instructions.size()); - std::map next_uses; for (std::pair>& pair : - ctx.next_use_distances_end[block->index]) - next_uses.insert({pair.first, pair.second.second + block->instructions.size()}); + ctx.next_use_distances_end[block->index]) { + local_next_uses[block->instructions.size() - 1].insert( + {pair.first, pair.second.second + block->instructions.size()}); + } for (int idx = block->instructions.size() - 1; idx >= 0; idx--) { aco_ptr& instr = block->instructions[idx]; @@ -371,19 +372,24 @@ local_next_uses(spill_ctx& ctx, Block* block) if (instr->opcode == aco_opcode::p_phi || instr->opcode == aco_opcode::p_linear_phi) break; + if (idx != (int)block->instructions.size() - 1) { + local_next_uses[idx] = local_next_uses[idx + 1]; + } + for (const Operand& op : instr->operands) { if (op.isFixed() && op.physReg() == exec) continue; if (op.regClass().type() == RegType::vgpr && op.regClass().is_linear()) continue; - if (op.isTemp()) - next_uses[op.getTemp()] = idx; + if (op.isTemp()) { + local_next_uses[idx][op.getTemp()] = idx; + } } for (const Definition& def : instr->definitions) { - if (def.isTemp()) - next_uses.erase(def.getTemp()); + if (def.isTemp()) { + local_next_uses[idx].erase(def.getTemp()); + } } - local_next_uses[idx] = next_uses; } return local_next_uses; } -- 2.7.4