From 5ebefceb42e8e2b1274db21dc3fec8050a33c345 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 19 Jan 2026 15:52:31 +0000 Subject: [PATCH] aco/ra: move split_blocking_vectors higher 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 | 70 ++++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 716c1c67277..4c4f47f2861 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -2351,6 +2351,41 @@ operand_can_use_reg(amd_gfx_level gfx_level, aco_ptr& instr, unsign } } +std::vector +split_blocking_vectors(ra_ctx& ctx, std::vector& vars, RegisterFile& register_file) +{ + std::vector splits; + + for (unsigned id : vars) { + RegClass rc = ctx.program->temp_rc[id]; + if (rc.size() == 1) + continue; + + Operand split_op(Temp(id, rc), ctx.assignments[id].reg); + small_vec defs; + for (unsigned offset = 0; offset < rc.bytes();) { + PhysReg reg = split_op.physReg().advance(offset); + unsigned size = MIN2(4, rc.bytes() - offset) - reg.byte(); + Definition def(ctx.program->allocateTmp(RegClass::get(rc.type(), size)), reg); + + defs.push_back(def); + ctx.assignments.emplace_back(def.physReg(), def.regClass()); + register_file.fill(def); + + offset += def.bytes(); + } + + aco_ptr split = aco_ptr( + create_instruction(aco_opcode::p_split_vector, Format::PSEUDO, 1, defs.size())); + split->operands[0] = split_op; + std::copy(defs.begin(), defs.end(), split->definitions.begin()); + + splits.push_back(split.release()); + } + + return splits; +} + void handle_fixed_operands(ra_ctx& ctx, RegisterFile& register_file, std::vector& parallelcopy, aco_ptr& instr) @@ -3660,41 +3695,6 @@ emit_parallel_copy(ra_ctx& ctx, std::vector& copies, register_file); } -std::vector -split_blocking_vectors(ra_ctx& ctx, std::vector& vars, RegisterFile& register_file) -{ - std::vector splits; - - for (unsigned id : vars) { - RegClass rc = ctx.program->temp_rc[id]; - if (rc.size() == 1) - continue; - - Operand split_op(Temp(id, rc), ctx.assignments[id].reg); - small_vec defs; - for (unsigned offset = 0; offset < rc.bytes();) { - PhysReg reg = split_op.physReg().advance(offset); - unsigned size = MIN2(4, rc.bytes() - offset) - reg.byte(); - Definition def(ctx.program->allocateTmp(RegClass::get(rc.type(), size)), reg); - - defs.push_back(def); - ctx.assignments.emplace_back(def.physReg(), def.regClass()); - register_file.fill(def); - - offset += def.bytes(); - } - - aco_ptr split = aco_ptr( - create_instruction(aco_opcode::p_split_vector, Format::PSEUDO, 1, defs.size())); - split->operands[0] = split_op; - std::copy(defs.begin(), defs.end(), split->definitions.begin()); - - splits.push_back(split.release()); - } - - return splits; -} - void recreate_blocking_vectors(ra_ctx& ctx, const std::vector& splits, std::vector>& instructions, RegisterFile& reg_file)