From ebd8ab17578d0e823ec96d921e4052fdc1820ff0 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 16 Nov 2020 14:43:28 +0000 Subject: [PATCH] aco: remove rollback code in get_reg_create_vector() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 22 +++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index e88a1c5c873..1a9235d5b37 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -1399,15 +1399,16 @@ PhysReg get_reg_create_vector(ra_ctx& ctx, return get_reg(ctx, reg_file, temp, parallelcopies, instr); /* re-enable killed operands which are in the wrong position */ + RegisterFile tmp_file(reg_file); for (unsigned i = 0, offset = 0; i < instr->operands.size(); offset += instr->operands[i].bytes(), i++) { if (instr->operands[i].isTemp() && instr->operands[i].isFirstKillBeforeDef() && instr->operands[i].physReg().reg_b != best_pos * 4 + offset) - reg_file.fill(instr->operands[i]); + tmp_file.fill(instr->operands[i]); } /* collect variables to be moved */ - std::set> vars = collect_vars(ctx, reg_file, PhysReg{best_pos}, size); + std::set> vars = collect_vars(ctx, tmp_file, PhysReg{best_pos}, size); for (unsigned i = 0, offset = 0; i < instr->operands.size(); offset += instr->operands[i].bytes(), i++) { if (!instr->operands[i].isTemp() || !instr->operands[i].isFirstKillBeforeDef() || @@ -1420,28 +1421,18 @@ PhysReg get_reg_create_vector(ra_ctx& ctx, */ if (ctx.program->chip_class >= GFX9 && !correct_pos) { vars.emplace(instr->operands[i].bytes(), instr->operands[i].tempId()); - reg_file.clear(instr->operands[i]); + tmp_file.clear(instr->operands[i]); /* fill operands which are in the correct position to avoid overwriting */ } else if (correct_pos) { - reg_file.fill(instr->operands[i]); + tmp_file.fill(instr->operands[i]); } } ASSERTED bool success = false; - success = get_regs_for_copies(ctx, reg_file, parallelcopies, vars, lb, ub, instr, best_pos, best_pos + size - 1); + success = get_regs_for_copies(ctx, tmp_file, parallelcopies, vars, lb, ub, instr, best_pos, best_pos + size - 1); assert(success); - update_renames(ctx, reg_file, parallelcopies, instr, false); adjust_max_used_regs(ctx, rc, best_pos); - /* remove killed operands from reg_file once again */ - for (unsigned i = 0; i < instr->operands.size(); i++) { - if (!instr->operands[i].isTemp() || !instr->operands[i].isFixed()) - continue; - assert(!instr->operands[i].isUndefined()); - if (instr->operands[i].isFirstKillBeforeDef()) - reg_file.clear(instr->operands[i]); - } - return PhysReg{best_pos}; } @@ -2232,6 +2223,7 @@ void register_allocation(Program *program, std::vector& live_out_per_bloc } else if (instr->opcode == aco_opcode::p_create_vector) { PhysReg reg = get_reg_create_vector(ctx, register_file, definition->getTemp(), parallelcopy, instr); + update_renames(ctx, register_file, parallelcopy, instr, false); definition->setFixed(reg); }