aco/live_var_analysis: ignore dead phis

Since we don't emit code for dead phis, we also don't
have to keep their operands around.

Totals from 44 (0.06% of 79395) affected shaders: (GFX11)

MaxWaves: 648 -> 650 (+0.31%)
Instrs: 449898 -> 449120 (-0.17%); split: -0.18%, +0.00%
CodeSize: 2395000 -> 2389300 (-0.24%); split: -0.24%, +0.00%
VGPRs: 5504 -> 5468 (-0.65%)
Latency: 9005058 -> 9000966 (-0.05%); split: -0.07%, +0.03%
InvThroughput: 2154567 -> 2139095 (-0.72%); split: -0.77%, +0.06%
VClause: 8362 -> 8354 (-0.10%)
SClause: 9135 -> 9134 (-0.01%)
Copies: 60678 -> 60118 (-0.92%); split: -0.93%, +0.01%
Branches: 14379 -> 14385 (+0.04%)
PreSGPRs: 3877 -> 3863 (-0.36%)
PreVGPRs: 6318 -> 6286 (-0.51%)
VALU: 266975 -> 266301 (-0.25%); split: -0.25%, +0.00%
SALU: 52741 -> 52667 (-0.14%); split: -0.15%, +0.01%
VMEM: 16140 -> 16132 (-0.05%)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29804>
This commit is contained in:
Daniel Schürmann
2024-06-18 17:09:05 +02:00
committed by Marge Bot
parent 708e1a73f5
commit 634051f913

View File

@@ -176,14 +176,13 @@ process_live_temps_per_block(Program* program, Block* block, unsigned& worklist,
/* handle phi definitions */
uint16_t linear_phi_defs = 0;
int phi_idx = idx;
while (phi_idx >= 0) {
for (int phi_idx = 0; phi_idx <= idx; phi_idx++) {
register_demand[phi_idx] = new_demand;
Instruction* insn = block->instructions[phi_idx].get();
assert(is_phi(insn) && insn->definitions.size() == 1);
if (!insn->definitions[0].isTemp()) {
assert(insn->definitions[0].isFixed() && insn->definitions[0].physReg() == exec);
phi_idx--;
continue;
}
Definition& definition = insn->definitions[0];
@@ -194,17 +193,13 @@ process_live_temps_per_block(Program* program, Block* block, unsigned& worklist,
if (n) {
definition.setKill(false);
if (insn->opcode == aco_opcode::p_linear_phi) {
assert(definition.getTemp().type() == RegType::sgpr);
linear_phi_defs += definition.size();
}
} else {
new_demand += temp;
definition.setKill(true);
}
if (insn->opcode == aco_opcode::p_linear_phi) {
assert(definition.getTemp().type() == RegType::sgpr);
linear_phi_defs += definition.size();
}
phi_idx--;
}
for (unsigned pred_idx : block->linear_preds)
@@ -245,11 +240,12 @@ process_live_temps_per_block(Program* program, Block* block, unsigned& worklist,
}
/* handle phi operands */
phi_idx = idx;
while (phi_idx >= 0) {
register_demand[phi_idx] = new_demand;
for (int phi_idx = 0; phi_idx <= idx; phi_idx++) {
Instruction* insn = block->instructions[phi_idx].get();
assert(is_phi(insn));
/* Ignore dead phis. */
if (insn->definitions[0].isKill())
continue;
/* directly insert into the predecessors live-out set */
Block::edge_vec& preds =
insn->opcode == aco_opcode::p_phi ? block->logical_preds : block->linear_preds;
@@ -274,7 +270,6 @@ process_live_temps_per_block(Program* program, Block* block, unsigned& worklist,
/* set if the operand is killed by this (or another) phi instruction */
operand.setKill(!live.count(operand.tempId()));
}
phi_idx--;
}
block->live_in_demand = new_demand;