From 7ce527a4fed1706aed9ced8e5d3432cc5abfbbd3 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 8 May 2020 19:01:09 +0100 Subject: [PATCH] aco: improve phi affinities with p_split_vector MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Totals from 5860 (4.59% of 127638) affected shaders: VGPRs: 460212 -> 460216 (+0.00%) CodeSize: 65554356 -> 65464816 (-0.14%) Instrs: 12655972 -> 12633578 (-0.18%) Copies: 1309994 -> 1292163 (-1.36%) Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 897a5bc50c7..a5c8ba784f4 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -64,6 +64,7 @@ struct ra_ctx { std::unordered_map phi_map; std::unordered_map affinities; std::unordered_map vectors; + std::unordered_map split_vectors; aco_ptr pseudo_dummy; unsigned max_used_sgpr = 0; unsigned max_used_vgpr = 0; @@ -919,6 +920,21 @@ PhysReg get_reg(ra_ctx& ctx, std::vector>& parallelcopies, aco_ptr& instr) { + auto split_vec = ctx.split_vectors.find(temp.id()); + if (split_vec != ctx.split_vectors.end()) { + unsigned offset = 0; + for (Definition def : split_vec->second->definitions) { + auto affinity_it = ctx.affinities.find(def.tempId()); + if (affinity_it != ctx.affinities.end() && ctx.assignments[affinity_it->second].assigned) { + PhysReg reg = ctx.assignments[affinity_it->second].reg; + reg.reg_b -= offset; + if (get_reg_specified(ctx, reg_file, temp.regClass(), parallelcopies, instr, reg)) + return reg; + } + offset += def.bytes(); + } + } + if (ctx.affinities.find(temp.id()) != ctx.affinities.end() && ctx.assignments[ctx.affinities[temp.id()]].assigned) { PhysReg reg = ctx.assignments[ctx.affinities[temp.id()]].reg; @@ -1435,6 +1451,9 @@ void register_allocation(Program *program, std::vector& live_out_per_bl } } + if (instr->opcode == aco_opcode::p_split_vector && instr->operands[0].isFirstKillBeforeDef()) + ctx.split_vectors[instr->operands[0].tempId()] = instr.get(); + /* add operands to live variables */ for (const Operand& op : instr->operands) { if (op.isTemp()) -- 2.30.2