From a834d9ef86a34dde64a379cae35e987466308918 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 15 Oct 2020 14:49:34 +0100 Subject: [PATCH] aco: expand vectors passed as copy operands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most copies which hit this case use p_create_vector, but in the future p_parallelcopy will be used instead. Signed-off-by: Rhys Perry Reviewed-by: Timur Kristóf Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_optimizer.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 22497a10452..c839e0696a3 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -1212,6 +1212,27 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr& instr) case aco_opcode::s_mov_b32: /* propagate */ case aco_opcode::s_mov_b64: case aco_opcode::v_mov_b32: + if (instr->operands[0].isTemp() && ctx.info[instr->operands[0].tempId()].is_vec() && + instr->operands[0].regClass() != instr->definitions[0].regClass()) { + /* We might not be able to copy-propagate if it's a SGPR->VGPR copy, so + * duplicate the vector instead. + */ + Instruction *vec = ctx.info[instr->operands[0].tempId()].instr; + aco_ptr old_copy = std::move(instr); + + instr.reset(create_instruction(aco_opcode::p_create_vector, Format::PSEUDO, vec->operands.size(), 1)); + instr->definitions[0] = old_copy->definitions[0]; + std::copy(vec->operands.begin(), vec->operands.end(), instr->operands.begin()); + for (unsigned i = 0; i < vec->operands.size(); i++) { + Operand& op = instr->operands[i]; + if (op.isTemp() && ctx.info[op.tempId()].is_temp() && + ctx.info[op.tempId()].temp.type() == instr->definitions[0].regClass().type()) + op.setTemp(ctx.info[op.tempId()].temp); + } + ctx.info[instr->definitions[0].tempId()].set_vec(instr.get()); + break; + } + /* fallthrough */ case aco_opcode::p_as_uniform: if (instr->definitions[0].isFixed()) { /* don't copy-propagate copies into fixed registers */