From b14bd285f8f48bdb495f9902282ffc0c178fcb70 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 23 Jun 2021 16:29:21 +0200 Subject: [PATCH] aco/ra: handle copies of copies better Instead of adding a second copy, just redirect the existing copy. No fossil-db changes. Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index b0b8915..b344fb5 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -726,18 +726,33 @@ void update_renames(ra_ctx& ctx, RegisterFile& reg_file, if (is_def) continue; - std::pair& copy = *it; - /* check if we moved another parallelcopy definition */ for (std::pair& other : parallelcopies) { if (!other.second.isTemp()) continue; - if (copy.first.getTemp() == other.second.getTemp()) { - copy.first.setTemp(other.first.getTemp()); - copy.first.setFixed(other.first.physReg()); + if (it->first.getTemp() == other.second.getTemp()) { + other.second.setFixed(it->second.physReg()); + ctx.assignments[other.second.tempId()].reg = other.second.physReg(); + it = parallelcopies.erase(it); + is_def = true; + /* check if we moved an operand, again */ + bool fill = true; + for (Operand& op : instr->operands) { + if (op.isTemp() && op.tempId() == other.second.tempId()) { + // FIXME: ensure that the operand can use this reg + op.setFixed(other.second.physReg()); + fill = (flags & fill_killed_ops) || !op.isKillBeforeDef(); + } + } + if (fill) + reg_file.fill(other.second); + break; } } + if (is_def) + continue; + std::pair& copy = *it; copy.second.setTemp(ctx.program->allocateTmp(copy.second.regClass())); ctx.assignments.emplace_back(copy.second.physReg(), copy.second.regClass()); assert(ctx.assignments.size() == ctx.program->peekAllocationId()); -- 2.7.4