aco: consider branch definitions in spiller

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Cc: 20.2 <mesa-stable>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6212>
(cherry picked from commit 8f6a900d5e)
This commit is contained in:
Rhys Perry 2020-08-04 17:08:43 +01:00 committed by Dylan Baker
parent 51c029f77a
commit bbc9b56a67
2 changed files with 15 additions and 1 deletions

View file

@ -760,7 +760,7 @@
"description": "aco: consider branch definitions in spiller",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},

View file

@ -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<int16_t>(
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<int16_t>(
reg_pressure.sgpr, ctx.register_demand[pred].back().sgpr - spilled_registers.sgpr);
}
while (reg_pressure.sgpr > ctx.target_pressure.sgpr) {
assert(!partial_spills.empty());