aco: Keep live-though variables and constants spilled.

This noticably reduces the amount of dead code emitted by our
spiller, when eg. previously a constant was spilled then
rematerialized before a loop, but then spilled again inside the loop.

Fossil DB changes on Navi 10:
Totals from 263 (0.19% of 139391) affected shaders:
VGPRs: 30044 -> 30028 (-0.05%)
SpillSGPRs: 8800 -> 4948 (-43.77%)
CodeSize: 4496040 -> 4335448 (-3.57%); split: -3.57%, +0.00%
Instrs: 843942 -> 819219 (-2.93%); split: -2.93%, +0.00%
Cycles: 76485744 -> 73549080 (-3.84%); split: -4.04%, +0.20%
VMEM: 38204 -> 38147 (-0.15%); split: +0.08%, -0.23%
SMEM: 17872 -> 17959 (+0.49%)
SClause: 24298 -> 24012 (-1.18%)
Copies: 98023 -> 82960 (-15.37%); split: -15.38%, +0.01%
Branches: 29074 -> 27632 (-4.96%)
PreVGPRs: 25291 -> 25241 (-0.20%)

Co-authored-by: Daniel Schürmann <daniel@schuermann.dev>
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8026>
This commit is contained in:
Timur Kristóf 2020-11-25 19:57:05 +01:00 committed by Marge Bot
parent 9f43b44bf0
commit b03fbec4f1
1 changed files with 11 additions and 10 deletions

View File

@ -384,18 +384,19 @@ RegisterDemand init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_id
}
unsigned loop_end = i;
/* keep live-through spilled */
for (std::pair<Temp, std::pair<uint32_t, uint32_t>> pair : ctx.next_use_distances_end[block_idx - 1]) {
if (pair.second.first < loop_end)
for (auto spilled : ctx.spills_exit[block_idx - 1]) {
auto map = ctx.next_use_distances_end[block_idx - 1];
auto it = map.find(spilled.first);
/* variable is not even live at the predecessor: probably from a phi */
if (it == map.end())
continue;
Temp to_spill = pair.first;
auto it = ctx.spills_exit[block_idx - 1].find(to_spill);
if (it == ctx.spills_exit[block_idx - 1].end())
continue;
ctx.spills_entry[block_idx][to_spill] = it->second;
spilled_registers += to_spill;
/* keep constants and live-through variables spilled */
if (it->second.first >= loop_end || ctx.remat.count(spilled.first)) {
ctx.spills_entry[block_idx][spilled.first] = spilled.second;
spilled_registers += spilled.first;
}
}
/* select live-through vgpr variables */