From ee0f7848581c813eb16d31a0da552c7797bfac13 Mon Sep 17 00:00:00 2001 From: Natalie Vock Date: Sat, 5 Apr 2025 13:04:19 +0200 Subject: [PATCH] aco/ra: Don't consider precolored ops/defs in get_reg_impl Reviewed-by: Rhys Perry 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 70638fe6636..0a9083f7a11 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -1280,8 +1280,15 @@ get_reg_impl(ra_ctx& ctx, const RegisterFile& reg_file, std::vector is_killed_operand; /* per-register */ + std::bitset<256> is_precolored; /* per-register */ for (unsigned j = 0; !is_phi(instr) && j < instr->operands.size(); j++) { Operand& op = instr->operands[j]; + if (op.isTemp() && op.isPrecolored() && !op.isFirstKillBeforeDef() && + bounds.contains(op.physReg())) { + for (unsigned i = 0; i < op.size(); ++i) { + is_precolored[(op.physReg() & 0xff) + i] = true; + } + } if (op.isTemp() && op.isFirstKillBeforeDef() && bounds.contains(op.physReg()) && !reg_file.test(PhysReg{op.physReg().reg()}, align(op.bytes() + op.physReg().byte(), 4))) { assert(op.isFixed()); @@ -1293,6 +1300,14 @@ get_reg_impl(ra_ctx& ctx, const RegisterFile& reg_file, std::vectordefinitions.size(); j++) { + Definition& def = instr->definitions[j]; + if (def.isTemp() && def.isPrecolored() && bounds.contains(def.physReg())) { + for (unsigned i = 0; i < def.size(); ++i) { + is_precolored[(def.physReg() & 0xff) + i] = true; + } + } + } assert((regs_free + ctx.num_linear_vgprs) >= size); @@ -1337,6 +1352,10 @@ get_reg_impl(ra_ctx& ctx, const RegisterFile& reg_file, std::vector