Mesa (staging/22.0): aco: fix spilling of phis without temp operands

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 20:58:21 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 4a846d12d1ce9a882d95528bdaa51ca09b805607
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a846d12d1ce9a882d95528bdaa51ca09b805607

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed May 25 16:12:19 2022 +0200

aco: fix spilling of phis without temp operands

These were spilled unconditionally.

Cc: mesa-stable
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16708>
(cherry picked from commit 8e41c66639f20671957ffd8cacd7c7328920848e)

---

 .pick_status.json              |  2 +-
 src/amd/compiler/aco_spill.cpp | 23 ++++++++++-------------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 8d8bea78190..6f4434ec550 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -228,7 +228,7 @@
         "description": "aco: fix spilling of phis without temp operands",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "because_sha": null
     },
     {
diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp
index ce1d830920b..cfb74e84a0b 100644
--- a/src/amd/compiler/aco_spill.cpp
+++ b/src/amd/compiler/aco_spill.cpp
@@ -697,25 +697,22 @@ init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_idx)
 
       std::vector<unsigned>& preds =
          phi->opcode == aco_opcode::p_phi ? block->logical_preds : block->linear_preds;
-      bool spill = true;
-
+      bool is_all_spilled = true;
       for (unsigned i = 0; i < phi->operands.size(); i++) {
-         /* non-temp operands can increase the register pressure */
-         if (!phi->operands[i].isTemp()) {
-            partial_spills.insert(phi->definitions[0].getTemp());
+         if (phi->operands[i].isUndefined())
             continue;
-         }
-
-         if (!ctx.spills_exit[preds[i]].count(phi->operands[i].getTemp()))
-            spill = false;
-         else
-            partial_spills.insert(phi->definitions[0].getTemp());
+         is_all_spilled &= phi->operands[i].isTemp() &&
+                           ctx.spills_exit[preds[i]].count(phi->operands[i].getTemp());
       }
-      if (spill) {
+
+      if (is_all_spilled) {
+         /* The phi is spilled at all predecessors. Keep it spilled. */
          ctx.spills_entry[block_idx][phi->definitions[0].getTemp()] =
             ctx.allocate_spill_id(phi->definitions[0].regClass());
-         partial_spills.erase(phi->definitions[0].getTemp());
          spilled_registers += phi->definitions[0].getTemp();
+      } else {
+         /* Phis might increase the register pressure. */
+         partial_spills.insert(phi->definitions[0].getTemp());
       }
    }
 



More information about the mesa-commit mailing list