Mesa (staging/20.2): aco: update phi_map in add_subdword_operand()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 2 16:09:39 UTC 2020
Module: Mesa
Branch: staging/20.2
Commit: 1ddbe3aa11fec7f292cee4f547efade25414932b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ddbe3aa11fec7f292cee4f547efade25414932b
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Tue Oct 27 10:59:35 2020 +0000
aco: update phi_map in add_subdword_operand()
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Fixes: 56345b8c610 ("aco: allow reading/writing upper halves/bytes when possible")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7216>
(cherry picked from commit d4503a902057cb5ddb0b2099e3d6df5ef2ba656a)
---
.pick_status.json | 2 +-
src/amd/compiler/aco_register_allocation.cpp | 40 +++++++++++++++++-----------
2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 26201579243..fb4a52a8930 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1471,7 +1471,7 @@
"description": "aco: update phi_map in add_subdword_operand()",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "56345b8c610e06b2c6ccb0d0975e62f9a008e34e"
},
diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp
index 5ff028423b8..2e7935e2dee 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -38,8 +38,10 @@
namespace aco {
namespace {
+struct ra_ctx;
+
unsigned get_subdword_operand_stride(chip_class chip, const aco_ptr<Instruction>& instr, unsigned idx, RegClass rc);
-void add_subdword_operand(chip_class chip, aco_ptr<Instruction>& instr, unsigned idx, unsigned byte, RegClass rc);
+void add_subdword_operand(ra_ctx& ctx, aco_ptr<Instruction>& instr, unsigned idx, unsigned byte, RegClass rc);
std::pair<unsigned, unsigned> get_subdword_definition_info(Program *program, const aco_ptr<Instruction>& instr, RegClass rc);
void add_subdword_definition(Program *program, aco_ptr<Instruction>& instr, unsigned idx, PhysReg reg, bool is_partial);
@@ -352,8 +354,22 @@ unsigned get_subdword_operand_stride(chip_class chip, const aco_ptr<Instruction>
return 4;
}
-void add_subdword_operand(chip_class chip, aco_ptr<Instruction>& instr, unsigned idx, unsigned byte, RegClass rc)
+void update_phi_map(ra_ctx& ctx, Instruction *old, Instruction *instr)
{
+ for (Operand& op : instr->operands) {
+ if (!op.isTemp())
+ continue;
+ std::unordered_map<unsigned, phi_info>::iterator phi = ctx.phi_map.find(op.tempId());
+ if (phi != ctx.phi_map.end()) {
+ phi->second.uses.erase(old);
+ phi->second.uses.emplace(instr);
+ }
+ }
+}
+
+void add_subdword_operand(ra_ctx& ctx, aco_ptr<Instruction>& instr, unsigned idx, unsigned byte, RegClass rc)
+{
+ chip_class chip = ctx.program->chip_class;
if (instr->format == Format::PSEUDO || byte == 0)
return;
@@ -376,7 +392,9 @@ void add_subdword_operand(chip_class chip, aco_ptr<Instruction>& instr, unsigned
}
return;
} else if (can_use_SDWA(chip, instr)) {
- convert_to_SDWA(chip, instr);
+ aco_ptr<Instruction> tmp = convert_to_SDWA(chip, instr);
+ if (tmp)
+ update_phi_map(ctx, tmp.get(), instr.get());
return;
} else if (rc.bytes() == 2 && can_use_opsel(chip, instr->opcode, idx, byte / 2)) {
VOP3A_instruction *vop3 = static_cast<VOP3A_instruction *>(instr.get());
@@ -2233,7 +2251,7 @@ void register_allocation(Program *program, std::vector<TempSet>& live_out_per_bl
if (op.isTemp() && op.isFirstKill() && op.isLateKill())
register_file.clear(op);
if (op.isTemp() && op.physReg().byte() != 0)
- add_subdword_operand(program->chip_class, instr, i, op.physReg().byte(), op.regClass());
+ add_subdword_operand(ctx, instr, i, op.physReg().byte(), op.regClass());
}
/* emit parallelcopy */
@@ -2366,19 +2384,9 @@ void register_allocation(Program *program, std::vector<TempSet>& live_out_per_bl
aco_ptr<Instruction> tmp = std::move(instr);
Format format = asVOP3(tmp->format);
instr.reset(create_instruction<VOP3A_instruction>(tmp->opcode, format, tmp->operands.size(), tmp->definitions.size()));
- for (unsigned i = 0; i < instr->operands.size(); i++) {
- Operand& operand = tmp->operands[i];
- instr->operands[i] = operand;
- /* keep phi_map up to date */
- if (operand.isTemp()) {
- std::unordered_map<unsigned, phi_info>::iterator phi = ctx.phi_map.find(operand.tempId());
- if (phi != ctx.phi_map.end()) {
- phi->second.uses.erase(tmp.get());
- phi->second.uses.emplace(instr.get());
- }
- }
- }
+ std::copy(tmp->operands.begin(), tmp->operands.end(), instr->operands.begin());
std::copy(tmp->definitions.begin(), tmp->definitions.end(), instr->definitions.begin());
+ update_phi_map(ctx, tmp.get(), instr.get());
}
instructions.emplace_back(std::move(*it));
More information about the mesa-commit
mailing list