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