From 965bdf7db299fd8ba4afd5e4809b3fdf170e1b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 29 Apr 2022 17:05:10 +0200 Subject: [PATCH] aco/ra: fix live-range splits of phi definitions It could happen that at the time of a live-range split, a phi was not yet placed in the new instruction vector, and thus, instead of renamed, a new phi was created. Fixes: dEQP-VK.subgroups.ballot_broadcast.compute.subgroupbroadcast_i8vec2 Cc: mesa-stable Reviewed-by: Rhys Perry Part-of: (cherry picked from commit 58bd9a379efada22efc3d1ac0848f681c2dd811a) --- .pick_status.json | 2 +- src/amd/compiler/aco_register_allocation.cpp | 29 ++++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 036b0226072..aab3dbe8275 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -229,7 +229,7 @@ "description": "aco/ra: fix live-range splits of phi definitions", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 9560aed7742..a6867af82be 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -2052,12 +2052,18 @@ void get_regs_for_phis(ra_ctx& ctx, Block& block, RegisterFile& register_file, std::vector>& instructions, IDSet& live_in) { - /* assign phis with all-matching registers to that register */ + /* move all phis to instructions */ for (aco_ptr& phi : block.instructions) { if (!is_phi(phi)) break; + if (!phi->definitions[0].isKill()) + instructions.emplace_back(std::move(phi)); + } + + /* assign phis with all-matching registers to that register */ + for (aco_ptr& phi : instructions) { Definition& definition = phi->definitions[0]; - if (definition.isKill() || definition.isFixed()) + if (definition.isFixed()) continue; if (!phi->operands[0].isTemp()) @@ -2079,11 +2085,9 @@ get_regs_for_phis(ra_ctx& ctx, Block& block, RegisterFile& register_file, } /* try to find a register that is used by at least one operand */ - for (aco_ptr& phi : block.instructions) { - if (!is_phi(phi)) - break; + for (aco_ptr& phi : instructions) { Definition& definition = phi->definitions[0]; - if (definition.isKill() || definition.isFixed()) + if (definition.isFixed()) continue; /* use affinity if available */ @@ -2116,25 +2120,16 @@ get_regs_for_phis(ra_ctx& ctx, Block& block, RegisterFile& register_file, } /* find registers for phis where the register was blocked or no operand was assigned */ - for (aco_ptr& phi : block.instructions) { - if (!is_phi(phi)) - break; - + for (aco_ptr& phi : instructions) { Definition& definition = phi->definitions[0]; - if (definition.isKill()) + if (definition.isFixed()) continue; - if (definition.isFixed()) { - instructions.emplace_back(std::move(phi)); - continue; - } - definition.setFixed( get_reg_phi(ctx, live_in, register_file, instructions, block, phi, definition.getTemp())); register_file.fill(definition); ctx.assignments[definition.tempId()].set(definition); - instructions.emplace_back(std::move(phi)); } }