Mesa (main): aco/ra: handle copies of definition registers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 24 17:12:19 UTC 2021


Module: Mesa
Branch: main
Commit: 995e218993767651c128cd89c5f90b6684fb4b50
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=995e218993767651c128cd89c5f90b6684fb4b50

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Jun 23 15:53:43 2021 +0200

aco/ra: handle copies of definition registers

Previously, it could happen that a parallelcopy of
a definition was inserted before the instruction.

Fixes Rage 2 with GFX7.

No fossil-db changes.

Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11571>

---

 src/amd/compiler/aco_register_allocation.cpp | 32 +++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp
index e52424044c4..b0b891554a7 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -703,12 +703,32 @@ void update_renames(ra_ctx& ctx, RegisterFile& reg_file,
    }
 
    /* allocate id's and rename operands: this is done transparently here */
-   for (std::pair<Operand, Definition>& copy : parallelcopies) {
-      /* the definitions with id are not from this function and already handled */
-      if (copy.second.isTemp())
+   auto it = parallelcopies.begin();
+   while (it != parallelcopies.end()) {
+      if (it->second.isTemp()) {
+         ++it;
+         continue;
+      }
+
+      /* check if we moved a definition: change the register and remove copy */
+      bool is_def = false;
+      for (Definition& def : instr->definitions) {
+         if (def.isTemp() && def.getTemp() == it->first.getTemp()) {
+            // FIXME: ensure that the definition can use this reg
+            def.setFixed(it->second.physReg());
+            reg_file.fill(def);
+            ctx.assignments[def.tempId()].reg = def.physReg();
+            it = parallelcopies.erase(it);
+            is_def = true;
+            break;
+         }
+      }
+      if (is_def)
          continue;
 
-      /* check if we we moved another parallelcopy definition */
+      std::pair<Operand, Definition>& copy = *it;
+
+      /* check if we moved another parallelcopy definition */
       for (std::pair<Operand, Definition>& other : parallelcopies) {
          if (!other.second.isTemp())
             continue;
@@ -717,7 +737,7 @@ void update_renames(ra_ctx& ctx, RegisterFile& reg_file,
             copy.first.setFixed(other.first.physReg());
          }
       }
-      // FIXME: if a definition got moved, change the target location and remove the parallelcopy
+
       copy.second.setTemp(ctx.program->allocateTmp(copy.second.regClass()));
       ctx.assignments.emplace_back(copy.second.physReg(), copy.second.regClass());
       assert(ctx.assignments.size() == ctx.program->peekAllocationId());
@@ -754,6 +774,8 @@ void update_renames(ra_ctx& ctx, RegisterFile& reg_file,
 
       if (fill)
          reg_file.fill(copy.second);
+
+      ++it;
    }
 }
 



More information about the mesa-commit mailing list