From a667d9a68d9821d02cf8f1ed8ed945af9875dd37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 25 Jul 2025 11:02:51 +0200 Subject: [PATCH] aco/ra: propagate precolor affinities through phis Totals from 917 (1.15% of 79839) affected shaders: (Navi48) Instrs: 3217861 -> 3216947 (-0.03%); split: -0.04%, +0.01% CodeSize: 17427204 -> 17432264 (+0.03%); split: -0.06%, +0.09% VGPRs: 65328 -> 65316 (-0.02%) Latency: 35336268 -> 35335528 (-0.00%); split: -0.01%, +0.01% InvThroughput: 7305032 -> 7302187 (-0.04%); split: -0.04%, +0.00% SClause: 120537 -> 120553 (+0.01%); split: -0.01%, +0.02% Copies: 307257 -> 306852 (-0.13%); split: -0.21%, +0.08% Branches: 115744 -> 115743 (-0.00%) VALU: 1572522 -> 1572183 (-0.02%); split: -0.02%, +0.00% SALU: 574229 -> 574155 (-0.01%); split: -0.05%, +0.04% Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 688b21798b2..33c23bfe85c 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -3149,21 +3149,24 @@ get_affinities(ra_ctx& ctx) continue; assert(instr->definitions[0].isTemp()); - auto it = temp_to_phi_resources.find(instr->definitions[0].tempId()); + Temp def = instr->definitions[0].getTemp(); + auto it = temp_to_phi_resources.find(def.id()); unsigned index = phi_resources.size(); std::vector* affinity_related; if (it != temp_to_phi_resources.end()) { index = it->second; - phi_resources[index][0] = instr->definitions[0].getTemp(); + phi_resources[index][0] = def; affinity_related = &phi_resources[index]; } else { - phi_resources.emplace_back(std::vector{instr->definitions[0].getTemp()}); + phi_resources.emplace_back(std::vector{def}); affinity_related = &phi_resources.back(); } for (const Operand& op : instr->operands) { - if (op.isTemp() && op.isKill() && op.regClass() == instr->definitions[0].regClass()) { + if (op.isTemp() && op.isKill() && op.regClass() == def.regClass()) { affinity_related->emplace_back(op.getTemp()); + if (ctx.assignments[def.id()].precolor_affinity) + ctx.assignments[op.tempId()].set_precolor_affinity(ctx.assignments[def.id()].reg); if (block.kind & block_kind_loop_header) continue; temp_to_phi_resources[op.tempId()] = index;