Mesa (staging/20.2): aco: don't assume src=lower when splitting self-intersecting copies
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Dec 7 20:46:35 UTC 2020
Module: Mesa
Branch: staging/20.2
Commit: 857b9f428ea6009da98dae447cbcb7a86b17bf2b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=857b9f428ea6009da98dae447cbcb7a86b17bf2b
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Thu Dec 3 19:55:10 2020 +0000
aco: don't assume src=lower when splitting self-intersecting copies
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Fixes: 09c584caeb2 ("aco: split self-intersecting copies instead of swapping")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7798>
(cherry picked from commit 2c40846ab6f8bf161dc79ed99b51702055c6d538)
---
.pick_status.json | 2 +-
src/amd/compiler/aco_lower_to_hw_instr.cpp | 29 +++++++++++++----------------
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 6fbb3bd2c6a..cbd1216abd0 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -589,7 +589,7 @@
"description": "aco: don't assume src=lower when splitting self-intersecting copies",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "09c584caeb2a1e7446ac2016ce7a7d8f0586774b"
},
diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp
index 1962c17032f..acbe52e99cb 100644
--- a/src/amd/compiler/aco_lower_to_hw_instr.cpp
+++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp
@@ -1532,31 +1532,28 @@ void handle_operands(std::map<PhysReg, copy_operation>& copy_map, lower_context*
/* if this is self-intersecting, we have to split it because
* self-intersecting swaps don't make sense */
- PhysReg lower = swap.def.physReg();
- PhysReg higher = swap.op.physReg();
- if (lower.reg_b > higher.reg_b)
- std::swap(lower, higher);
- if (higher.reg_b - lower.reg_b < (int)swap.bytes) {
- unsigned offset = higher.reg_b - lower.reg_b;
+ PhysReg src = swap.op.physReg(), dst = swap.def.physReg();
+ if (abs((int)src.reg_b - (int)dst.reg_b) < (int)swap.bytes) {
+ unsigned offset = abs((int)src.reg_b - (int)dst.reg_b);
RegType type = swap.def.regClass().type();
copy_operation middle;
- lower.reg_b += offset;
- higher.reg_b += offset;
+ 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(lower, RegClass::get(type, middle.bytes));
- middle.def = Definition(higher, RegClass::get(type, middle.bytes));
- copy_map[higher] = middle;
+ 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;
- lower.reg_b += middle.bytes;
- higher.reg_b += middle.bytes;
+ 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(lower, RegClass::get(type, end.bytes));
- end.def = Definition(higher, RegClass::get(type, end.bytes));
- copy_map[higher] = end;
+ end.op = Operand(src, RegClass::get(type, end.bytes));
+ end.def = Definition(dst, RegClass::get(type, end.bytes));
+ copy_map[dst] = end;
memset(swap.uses + offset, 0, swap.bytes - offset);
swap.bytes = offset;
More information about the mesa-commit
mailing list