From 5ecc800eddf36dbec4fe2d1cbb59af345cfeb3e4 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Thu, 27 Nov 2025 12:01:02 +0100 Subject: [PATCH] aco/optimizer: add second copy prop for pseudo instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Navi48: Totals from 28 (0.03% of 82405) affected shaders: Instrs: 144993 -> 144645 (-0.24%); split: -0.26%, +0.02% CodeSize: 784668 -> 783604 (-0.14%); split: -0.19%, +0.05% SpillVGPRs: 215 -> 209 (-2.79%) Latency: 2529900 -> 2526895 (-0.12%); split: -0.12%, +0.00% InvThroughput: 775379 -> 773859 (-0.20%); split: -0.20%, +0.00% VClause: 2815 -> 2803 (-0.43%) Copies: 23474 -> 23170 (-1.30%); split: -1.38%, +0.09% Branches: 4638 -> 4632 (-0.13%) VALU: 81924 -> 81620 (-0.37%); split: -0.40%, +0.03% SALU: 23986 -> 23995 (+0.04%); split: -0.03%, +0.07% VMEM: 3726 -> 3714 (-0.32%) Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_optimizer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 37f673f71a5..73a4699e4b6 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -4217,6 +4217,23 @@ combine_instruction(opt_ctx& ctx, aco_ptr& instr) /* Apply SDWA. Do this after label_instruction() so it can remove * label_extract if not all instructions can take SDWA. */ alu_propagate_temp_const(ctx, instr, true); + } else if (instr->isPseudo()) { + /* PSEUDO: propagate temporaries/constants */ + for (unsigned i = 0; i < instr->operands.size(); i++) { + Operand op = instr->operands[i]; + if (!op.isTemp()) + continue; + + ssa_info info = ctx.info[op.tempId()]; + while (info.is_temp()) { + if (pseudo_propagate_temp(ctx, instr, info.temp, i)) { + ctx.uses[info.temp.id()]++; + decrease_and_dce(ctx, op.getTemp()); + op = instr->operands[i]; + } + info = ctx.info[info.temp.id()]; + } + } } if (instr->isDPP())