From cb096b85ff14e62aba4275128d0c082e98a21d80 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 25 Aug 2023 19:21:54 +0100 Subject: [PATCH] aco/spill: skip p_branch in process_block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes compilation of a Dead by Daylight shader. fossil-db (gfx1100): Totals from 58 (0.04% of 133461) affected shaders: Instrs: 319824 -> 319421 (-0.13%); split: -0.13%, +0.00% CodeSize: 1711260 -> 1708744 (-0.15%); split: -0.15%, +0.00% SpillSGPRs: 2567 -> 2459 (-4.21%) Latency: 3274930 -> 3274921 (-0.00%); split: -0.00%, +0.00% InvThroughput: 924106 -> 924105 (-0.00%); split: -0.00%, +0.00% Copies: 41883 -> 41757 (-0.30%); split: -0.31%, +0.00% Branches: 9144 -> 9146 (+0.02%) Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9599 Part-of: --- src/amd/compiler/aco_spill.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 93b7c975252..38e25dba3df 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -1186,6 +1186,15 @@ process_block(spill_ctx& ctx, unsigned block_idx, Block* block, RegisterDemand s while (idx < block->instructions.size()) { aco_ptr& instr = block->instructions[idx]; + /* Spilling is handled as part of phis (they should always have the same or higher register + * demand). If we try to spill here, we might not be able to reduce the register demand enough + * because there is no path to spill constant/undef phi operands. */ + if (instr->opcode == aco_opcode::p_branch) { + instructions.emplace_back(std::move(instr)); + idx++; + continue; + } + std::map> reloads; /* rename and reload operands */