Mesa (main): aco: fix self-intersecting register swaps

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 13 07:31:32 UTC 2021


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

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Jul  7 17:41:56 2021 +0200

aco: fix self-intersecting register swaps

Splitting self-intersecting register swaps into
3 sections was unnecessary and only worked because
the middle section was always empty for full dword
swaps.

No fossil-db changes.

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

---

 src/amd/compiler/aco_lower_to_hw_instr.cpp | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp
index 4a1a2caf82d..979eba3eae6 100644
--- a/src/amd/compiler/aco_lower_to_hw_instr.cpp
+++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp
@@ -1716,23 +1716,14 @@ handle_operands(std::map<PhysReg, copy_operation>& copy_map, lower_context* ctx,
          unsigned offset = abs((int)src.reg_b - (int)dst.reg_b);
          RegType type = swap.def.regClass().type();
 
-         copy_operation middle;
+         copy_operation remaining;
          src.reg_b += offset;
          dst.reg_b += offset;
-         middle.bytes = swap.bytes - offset * 2;
-         memcpy(middle.uses, swap.uses + offset, middle.bytes);
-         middle.op = Operand(src, RegClass::get(type, middle.bytes));
-         middle.def = Definition(dst, RegClass::get(type, middle.bytes));
-         copy_map[dst] = middle;
-
-         copy_operation end;
-         src.reg_b += middle.bytes;
-         dst.reg_b += middle.bytes;
-         end.bytes = swap.bytes - (offset + middle.bytes);
-         memcpy(end.uses, swap.uses + offset + middle.bytes, end.bytes);
-         end.op = Operand(src, RegClass::get(type, end.bytes));
-         end.def = Definition(dst, RegClass::get(type, end.bytes));
-         copy_map[dst] = end;
+         remaining.bytes = swap.bytes - offset;
+         memcpy(remaining.uses, swap.uses + offset, remaining.bytes);
+         remaining.op = Operand(src, RegClass::get(type, remaining.bytes));
+         remaining.def = Definition(dst, RegClass::get(type, remaining.bytes));
+         copy_map[dst] = remaining;
 
          memset(swap.uses + offset, 0, swap.bytes - offset);
          swap.bytes = offset;



More information about the mesa-commit mailing list