From c04ef28c560e5b8eda3eaecc4cc4abb55bafe0bc Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 17 Apr 2025 16:59:53 +0100 Subject: [PATCH] aco: rename ops_fixed_to_def to tied_defs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is less words. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_ir.cpp | 2 +- src/amd/compiler/aco_ir.h | 3 ++- src/amd/compiler/aco_live_var_analysis.cpp | 9 +++++---- src/amd/compiler/aco_register_allocation.cpp | 12 ++++++------ src/amd/compiler/aco_validate.cpp | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/amd/compiler/aco_ir.cpp b/src/amd/compiler/aco_ir.cpp index 091612cbf5c..8d8bc7fe746 100644 --- a/src/amd/compiler/aco_ir.cpp +++ b/src/amd/compiler/aco_ir.cpp @@ -1423,7 +1423,7 @@ should_form_clause(const Instruction* a, const Instruction* b) } aco::small_vec -get_ops_fixed_to_def(Instruction* instr) +get_tied_defs(Instruction* instr) { aco::small_vec ops; if (instr->opcode == aco_opcode::v_interp_p2_f32 || instr->opcode == aco_opcode::v_mac_f32 || diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index cee83828b75..b7e5428a4c8 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -2328,7 +2328,8 @@ void _aco_err(Program* program, const char* file, unsigned line, const char* fmt #define aco_err(program, ...) _aco_err(program, __FILE__, __LINE__, __VA_ARGS__) -aco::small_vec get_ops_fixed_to_def(Instruction* instr); +/* Returns the indices of operands to which definitions are tied to. */ +aco::small_vec get_tied_defs(Instruction* instr); /* utilities for dealing with register demand */ RegisterDemand get_live_changes(Instruction* instr); diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp index b58b2a8ce2e..3837dd55f0f 100644 --- a/src/amd/compiler/aco_live_var_analysis.cpp +++ b/src/amd/compiler/aco_live_var_analysis.cpp @@ -245,10 +245,11 @@ process_live_temps_per_block(live_ctx& ctx, Block* block) } /* Check if a definition clobbers some operand */ - auto fixed_ops = get_ops_fixed_to_def(insn); - for (auto op_idx : fixed_ops) { - assert(std::none_of(fixed_ops.begin(), fixed_ops.end(), - [&](uint32_t i) { + auto tied_defs = get_tied_defs(insn); + for (auto op_idx : tied_defs) { + assert(std::none_of(tied_defs.begin(), tied_defs.end(), + [&](uint32_t i) + { return i != op_idx && insn->operands[i].getTemp() == insn->operands[op_idx].getTemp(); })); diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 33b6c15acd8..2a1c45d26d6 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -2147,8 +2147,8 @@ operand_can_use_reg(amd_gfx_level gfx_level, aco_ptr& instr, unsign FALLTHROUGH; case Format::SOP2: case Format::SOP1: { - auto fixed_ops = get_ops_fixed_to_def(instr.get()); - return std::all_of(fixed_ops.begin(), fixed_ops.end(), + auto tied_defs = get_tied_defs(instr.get()); + return std::all_of(tied_defs.begin(), tied_defs.end(), [idx](auto op_idx) { return op_idx != idx; }) || is_sgpr_writable_without_side_effects(gfx_level, reg); } @@ -2858,7 +2858,7 @@ get_affinities(ra_ctx& ctx) ctx.assignments[instr->operands[0].tempId()].m0 = true; } - auto ops_fixed_to_defs = get_ops_fixed_to_def(instr.get()); + auto tied_defs = get_tied_defs(instr.get()); for (unsigned i = 0; i < instr->definitions.size(); i++) { const Definition& def = instr->definitions[i]; if (!def.isTemp()) @@ -2872,8 +2872,8 @@ get_affinities(ra_ctx& ctx) Operand op; if (instr->opcode == aco_opcode::p_parallelcopy) { op = instr->operands[i]; - } else if (i < ops_fixed_to_defs.size()) { - op = instr->operands[ops_fixed_to_defs[i]]; + } else if (i < tied_defs.size()) { + op = instr->operands[tied_defs[i]]; } else if (vop3_can_use_vop2acc(ctx, instr.get())) { op = instr->operands[2]; } else if (i == 0 && sop2_can_use_sopk(ctx, instr.get())) { @@ -3299,7 +3299,7 @@ register_allocation(Program* program, ra_test_policy policy) * location because that's used by a live-through operand. */ unsigned fixed_def_idx = 0; - for (auto op_idx : get_ops_fixed_to_def(instr.get())) { + for (auto op_idx : get_tied_defs(instr.get())) { instr->definitions[fixed_def_idx++].setPrecolored(instr->operands[op_idx].physReg()); instr->operands[op_idx].setPrecolored(instr->operands[op_idx].physReg()); } diff --git a/src/amd/compiler/aco_validate.cpp b/src/amd/compiler/aco_validate.cpp index d14ab0115b5..1d246e2f8de 100644 --- a/src/amd/compiler/aco_validate.cpp +++ b/src/amd/compiler/aco_validate.cpp @@ -1474,7 +1474,7 @@ validate_ra(Program* program) } unsigned fixed_def_idx = 0; - for (auto op_idx : get_ops_fixed_to_def(instr.get())) { + for (auto op_idx : get_tied_defs(instr.get())) { if (instr->definitions[fixed_def_idx++].physReg() != instr->operands[op_idx].physReg()) { err |= ra_fail(program, loc, Location(),