summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schürmann <daniel@schuermann.dev>2020-12-11 14:30:30 +0100
committerDylan Baker <dylan.c.baker@intel.com>2020-12-16 11:09:09 -0800
commitc9497e286d3b3b13f5dc9dcea1eb486f6faf95cc (patch)
tree088d07a916896c742191f0d77c0c2d62a9db958a
parent5636ec0acec3e2b824144305462deacbb303c031 (diff)
aco: fix DCE of rematerializable phi operands
Otherwise, if a phi gets spilled, the operand might be considered unused. Fixes: d48d72e98af9436babeeb3a94b312f94bc582b36 ('aco: Initial commit of independent AMD compiler') Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8055> (cherry picked from commit 0bccfd86f6e97611a3b9b4f227aa414bc3d04e02)
-rw-r--r--.pick_status.json2
-rw-r--r--src/amd/compiler/aco_spill.cpp15
2 files changed, 8 insertions, 9 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 9a8dab7528d..0b790f27aa0 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -715,7 +715,7 @@
"description": "aco: fix DCE of rematerializable phi operands",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "d48d72e98af9436babeeb3a94b312f94bc582b36"
},
diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp
index 67c6712e0e4..1abfa04a940 100644
--- a/src/amd/compiler/aco_spill.cpp
+++ b/src/amd/compiler/aco_spill.cpp
@@ -815,6 +815,12 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx)
phi->opcode != aco_opcode::p_linear_phi)
break;
+ /* prevent it's definining instruction from being DCE'd if it could be rematerialized */
+ for (const Operand& op : phi->operands) {
+ if (op.isTemp() && ctx.remat.count(op.getTemp()))
+ ctx.remat_used[ctx.remat[op.getTemp()].instr] = true;
+ }
+
/* if the phi is not spilled, add to instructions */
if (ctx.spills_entry[block_idx].find(phi->definitions[0].getTemp()) == ctx.spills_entry[block_idx].end()) {
instructions.emplace_back(std::move(phi));
@@ -1076,14 +1082,7 @@ void process_block(spill_ctx& ctx, unsigned block_idx, Block* block,
/* phis are handled separetely */
while (block->instructions[idx]->opcode == aco_opcode::p_phi ||
block->instructions[idx]->opcode == aco_opcode::p_linear_phi) {
- aco_ptr<Instruction>& instr = block->instructions[idx];
- for (const Operand& op : instr->operands) {
- /* prevent it's definining instruction from being DCE'd if it could be rematerialized */
- if (op.isTemp() && ctx.remat.count(op.getTemp()))
- ctx.remat_used[ctx.remat[op.getTemp()].instr] = true;
- }
- instructions.emplace_back(std::move(instr));
- idx++;
+ instructions.emplace_back(std::move(block->instructions[idx++]));
}
if (block->register_demand.exceeds(ctx.target_pressure))