From 5a941f4d6dc1ea1d08ba3d9bfe4c5add97b0fde4 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 7 Jul 2020 18:16:47 +0100 Subject: [PATCH] aco: fix underestimated pressure in spiller when a phi has a killed def MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_spill.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 62ab69a045b..7db3248e20f 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -604,6 +604,17 @@ RegisterDemand init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_id } } } else { + for (unsigned i = 0; i < idx; i++) { + aco_ptr& instr = block->instructions[i]; + assert(is_phi(instr)); + /* Killed phi definitions increase pressure in the predecessor but not + * the block they're in. Since the loops below are both to control + * pressure of the start of this block and the ends of it's + * predecessors, we need to count killed unspilled phi definitions here. */ + if (instr->definitions[0].isKill() && + !ctx.spills_entry[block_idx].count(instr->definitions[0].getTemp())) + reg_pressure += instr->definitions[0].getTemp(); + } idx--; } reg_pressure += ctx.register_demand[block_idx][idx] - spilled_registers; -- 2.30.2