From 98136bda056e52941ab91c00181285d262ffde3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 7 Jul 2021 17:41:56 +0200 Subject: [PATCH] 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 Part-of: --- 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& 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;