Module: Mesa
Branch: staging/23.1
Commit: b5d66e01d82b68dcde3ee1430353661a165e5b8d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5d66e01d82b68dcde3ee1430353661a165e5b8d

Author: Rhys Perry <[email protected]>
Date:   Fri Aug 25 19:21:54 2023 +0100

aco/spill: skip p_branch in process_block

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 <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9599
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24896>
(cherry picked from commit cb096b85ff14e62aba4275128d0c082e98a21d80)

---

 .pick_status.json              | 2 +-
 src/amd/compiler/aco_spill.cpp | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 1f1286c6360..a31f03613ec 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -3118,7 +3118,7 @@
         "description": "aco/spill: skip p_branch in process_block",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp
index 805c480cfcd..3b3fb15b921 100644
--- a/src/amd/compiler/aco_spill.cpp
+++ b/src/amd/compiler/aco_spill.cpp
@@ -1179,6 +1179,15 @@ process_block(spill_ctx& ctx, unsigned block_idx, Block* 
block, RegisterDemand s
    while (idx < block->instructions.size()) {
       aco_ptr<Instruction>& 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<Temp, std::pair<Temp, uint32_t>> reloads;
 
       /* rename and reload operands */

Reply via email to