From 43b39013623464c06d63bf28daf0c26dd19d5acd Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 26 Nov 2025 15:42:47 +0000 Subject: [PATCH] aco/ra: copy vector_info to affinities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This eliminates some copies in BVH traversal loops. fossil-db (navi31): Totals from 200 (0.25% of 79825) affected shaders: Instrs: 734931 -> 732521 (-0.33%); split: -0.34%, +0.01% CodeSize: 3801080 -> 3791692 (-0.25%); split: -0.26%, +0.01% VGPRs: 13704 -> 13728 (+0.18%); split: -0.44%, +0.61% Latency: 6094605 -> 6082060 (-0.21%); split: -0.24%, +0.03% InvThroughput: 1081982 -> 1080121 (-0.17%); split: -0.19%, +0.02% VClause: 18835 -> 18837 (+0.01%); split: -0.01%, +0.02% Copies: 64602 -> 62239 (-3.66%); split: -3.75%, +0.09% Branches: 20111 -> 20112 (+0.00%); split: -0.01%, +0.02% VALU: 438618 -> 436257 (-0.54%); split: -0.55%, +0.01% SALU: 85092 -> 85085 (-0.01%); split: -0.01%, +0.00% VOPD: 76 -> 74 (-2.63%) Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Reviewed-by: Emre Cecanpunar Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 8262cb70921..93974074327 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -3252,11 +3252,20 @@ get_affinities(ra_ctx& ctx) } } } + /* create affinities */ for (std::vector& vec : phi_resources) { - for (unsigned i = 1; i < vec.size(); i++) - if (vec[i].id() != vec[0].id()) - ctx.assignments[vec[i].id()].affinity = vec[0].id(); + for (unsigned i = 1; i < vec.size(); i++) { + if (vec[i].id() == vec[0].id()) + continue; + + ctx.assignments[vec[i].id()].affinity = vec[0].id(); + + /* Propagate vector-info up the affinity-chain */ + auto it = ctx.vectors.find(vec[i].id()); + if (it != ctx.vectors.end() && !ctx.vectors.count(vec[0].id())) + ctx.vectors[vec[0].id()] = it->second; + } } }