Module: Mesa
Branch: staging/23.0
Commit: 54cf68b72b7eca2ba7b5c6a46154be2afc3b9372
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=54cf68b72b7eca2ba7b5c6a46154be2afc3b9372

Author: Timur Kristóf <[email protected]>
Date:   Sun Apr  2 22:11:25 2023 +0200

aco: Don't remove exec writes that also write other registers.

Don't eliminate an instruction that writes registers other than exec and scc.
It is possible that this is eg. an s_and_saveexec and the saved value is
used by a later branch.

Fixes: bc130497472cb4ec4ec60695ed99b169d6681118
Reviewed-by: Daniel Schürmann <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21493>
(cherry picked from commit 0211e66f65522caa1f6855b937ae4fc18af0c937)

---

 .pick_status.json                        |  2 +-
 src/amd/compiler/aco_ssa_elimination.cpp | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 1b2b8ccc3ac..0cf62b4b4bb 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -76,7 +76,7 @@
         "description": "aco: Don't remove exec writes that also write other 
registers.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "bc130497472cb4ec4ec60695ed99b169d6681118"
     },
diff --git a/src/amd/compiler/aco_ssa_elimination.cpp 
b/src/amd/compiler/aco_ssa_elimination.cpp
index 9a1a3dcf590..9c6fc90d80a 100644
--- a/src/amd/compiler/aco_ssa_elimination.cpp
+++ b/src/amd/compiler/aco_ssa_elimination.cpp
@@ -603,7 +603,15 @@ 
eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block)
 
       /* See if we found an unused exec write. */
       if (writes_exec && !exec_write_used) {
-         instr.reset();
+         /* Don't eliminate an instruction that writes registers other than 
exec and scc.
+          * It is possible that this is eg. an s_and_saveexec and the saved 
value is
+          * used by a later branch.
+          */
+         bool writes_other = std::any_of(instr->definitions.begin(), 
instr->definitions.end(),
+                                         [](const Definition& def) -> bool
+                                         { return def.physReg() != exec && 
def.physReg() != scc; });
+         if (!writes_other)
+            instr.reset();
          continue;
       }
 

Reply via email to