From 510f5e55be05e8d6061cda2f53d16abc6a35be55 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Thu, 25 Jul 2024 17:01:37 +0200 Subject: [PATCH] aco/gfx10+: set lateKill for sgprs used by wave64 VALU writing a mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RDNA2 ISA doc, 6.2.4. Wave64 Destination Restrictions: The first pass of a wave64 VALU instruction may not overwrite a scalar value used by the second half. Foz-DB Navi31: Totals from 5221 (6.58% of 79395) affected shaders: Instrs: 9751484 -> 9752179 (+0.01%); split: -0.01%, +0.01% CodeSize: 50624072 -> 50626088 (+0.00%); split: -0.00%, +0.01% Latency: 85646450 -> 85647419 (+0.00%); split: -0.00%, +0.00% InvThroughput: 15039160 -> 15039277 (+0.00%); split: -0.00%, +0.00% VClause: 200275 -> 200204 (-0.04%) SClause: 248645 -> 248607 (-0.02%); split: -0.03%, +0.01% Copies: 640802 -> 641413 (+0.10%); split: -0.01%, +0.11% PreSGPRs: 236297 -> 236735 (+0.19%) VALU: 5666449 -> 5666440 (-0.00%) SALU: 967482 -> 968111 (+0.07%); split: -0.01%, +0.07% Cc: mesa-stable Reviewed-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_live_var_analysis.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp index e5748df5c5f..fac93e84898 100644 --- a/src/amd/compiler/aco_live_var_analysis.cpp +++ b/src/amd/compiler/aco_live_var_analysis.cpp @@ -199,6 +199,21 @@ process_live_temps_per_block(live_ctx& ctx, Block* block) } } + if (ctx.program->gfx_level >= GFX10 && insn->isVALU() && + insn->definitions.back().regClass() == s2) { + /* RDNA2 ISA doc, 6.2.4. Wave64 Destination Restrictions: + * The first pass of a wave64 VALU instruction may not overwrite a scalar value used by + * the second half. + */ + bool carry_in = insn->opcode == aco_opcode::v_addc_co_u32 || + insn->opcode == aco_opcode::v_subb_co_u32 || + insn->opcode == aco_opcode::v_subbrev_co_u32; + for (unsigned op_idx = 0; op_idx < (carry_in ? 2 : insn->operands.size()); op_idx++) { + if (insn->operands[op_idx].isOfType(RegType::sgpr)) + insn->operands[op_idx].setLateKill(true); + } + } + /* we need to do this in a separate loop because the next one can * setKill() for several operands at once and we don't want to * overwrite that in a later iteration */