From c30e83cc515b826e14f412208ee01182c1abaddf Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Mon, 9 Nov 2020 10:52:45 +0100 Subject: [PATCH] aco/ra: Use PhysRegInterval for collect_vars parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 1946ae49274..ccf8248f893 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -851,10 +851,10 @@ std::pair get_reg_simple(ra_ctx& ctx, /* collect variables from a register area and clear reg_file */ std::set> collect_vars(ra_ctx& ctx, RegisterFile& reg_file, - PhysReg reg, unsigned size) + const PhysRegInterval reg_interval) { std::set> vars; - for (PhysReg j : PhysRegInterval { reg, size }) { + for (PhysReg j : reg_interval) { if (reg_file.is_blocked(j)) continue; if (reg_file[j] == 0xF0000000) { @@ -1017,7 +1017,7 @@ bool get_regs_for_copies(ra_ctx& ctx, PhysRegInterval reg_win { best_pos, size }; /* collect variables and block reg file */ - std::set> new_vars = collect_vars(ctx, reg_file, reg_win.lo(), size); + std::set> new_vars = collect_vars(ctx, reg_file, reg_win); /* mark the area as blocked */ reg_file.block(reg_win.lo(), var.rc); @@ -1157,7 +1157,7 @@ std::pair get_reg_impl(ra_ctx& ctx, /* now, we figured the placement for our definition */ RegisterFile tmp_file(reg_file); - std::set> vars = collect_vars(ctx, tmp_file, PhysReg{best_win.lo()}, size); + std::set> vars = collect_vars(ctx, tmp_file, best_win); if (instr->opcode == aco_opcode::p_create_vector) { /* move killed operands which aren't yet at the correct position (GFX9+) @@ -1457,7 +1457,7 @@ PhysReg get_reg_create_vector(ra_ctx& ctx, } /* collect variables to be moved */ - std::set> vars = collect_vars(ctx, tmp_file, best_pos, size); + std::set> vars = collect_vars(ctx, tmp_file, PhysRegInterval { 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() || @@ -2215,8 +2215,10 @@ void register_allocation(Program *program, std::vector& live_out_per_bloc adjust_max_used_regs(ctx, definition.regClass(), definition.physReg()); /* check if the target register is blocked */ if (register_file.test(definition.physReg(), definition.bytes())) { + const PhysRegInterval def_regs { definition.physReg(), definition.size() }; + /* create parallelcopy pair to move blocking vars */ - std::set> vars = collect_vars(ctx, register_file, definition.physReg(), definition.size()); + std::set> vars = collect_vars(ctx, register_file, def_regs); RegisterFile tmp_file(register_file); /* re-enable the killed operands, so that we don't move the blocking vars there */ @@ -2229,7 +2231,7 @@ void register_allocation(Program *program, std::vector& live_out_per_bloc DefInfo info(ctx, instr, definition.regClass(), -1); success = get_regs_for_copies(ctx, tmp_file, parallelcopy, vars, info.bounds, instr, - PhysRegInterval { definition.physReg(), definition.size() }); + def_regs); assert(success); update_renames(ctx, register_file, parallelcopy, instr, false);