From 8f6a900d5e5decd54f71ca89c950548089086c14 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 4 Aug 2020 17:08:43 +0100 Subject: [PATCH] aco: consider branch definitions in spiller MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Cc: 20.2 Part-of: --- src/amd/compiler/aco_spill.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 69d5cb23b23..9609d639fb3 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -451,6 +451,13 @@ RegisterDemand init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_id assert(idx != 0 && "loop without phis: TODO"); idx--; RegisterDemand reg_pressure = ctx.register_demand[block_idx][idx] - spilled_registers; + /* Consider register pressure from linear predecessors. This can affect + * reg_pressure if the branch instructions define sgprs. */ + for (unsigned pred : block->linear_preds) { + reg_pressure.sgpr = std::max( + reg_pressure.sgpr, ctx.register_demand[pred].back().sgpr - spilled_registers.sgpr); + } + while (reg_pressure.sgpr > ctx.target_pressure.sgpr) { unsigned distance = 0; Temp to_spill; @@ -629,6 +636,13 @@ RegisterDemand init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_id } reg_pressure += ctx.register_demand[block_idx][idx] - spilled_registers; + /* Consider register pressure from linear predecessors. This can affect + * reg_pressure if the branch instructions define sgprs. */ + for (unsigned pred : block->linear_preds) { + reg_pressure.sgpr = std::max( + reg_pressure.sgpr, ctx.register_demand[pred].back().sgpr - spilled_registers.sgpr); + } + while (reg_pressure.sgpr > ctx.target_pressure.sgpr) { assert(!partial_spills.empty()); -- 2.30.2