Mesa (main): aco/ra: handle copies of copies better

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


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

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Jun 23 16:29:21 2021 +0200

aco/ra: handle copies of copies better

Instead of adding a second copy, just redirect
the existing copy.

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 | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp
index b0b891554a7..b344fb5f9af 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -726,18 +726,33 @@ void update_renames(ra_ctx& ctx, RegisterFile& reg_file,
       if (is_def)
          continue;
 
-      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;
-         if (copy.first.getTemp() == other.second.getTemp()) {
-            copy.first.setTemp(other.first.getTemp());
-            copy.first.setFixed(other.first.physReg());
+         if (it->first.getTemp() == other.second.getTemp()) {
+            other.second.setFixed(it->second.physReg());
+            ctx.assignments[other.second.tempId()].reg = other.second.physReg();
+            it = parallelcopies.erase(it);
+            is_def = true;
+            /* check if we moved an operand, again */
+            bool fill = true;
+            for (Operand& op : instr->operands) {
+               if (op.isTemp() && op.tempId() == other.second.tempId()) {
+                  // FIXME: ensure that the operand can use this reg
+                  op.setFixed(other.second.physReg());
+                  fill = (flags & fill_killed_ops) || !op.isKillBeforeDef();
+               }
+            }
+            if (fill)
+               reg_file.fill(other.second);
+            break;
          }
       }
+      if (is_def)
+         continue;
 
+      std::pair<Operand, Definition>& copy = *it;
       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());



More information about the mesa-commit mailing list