aco: use bit vectors for liveness sets
This seems to be much faster than hash sets. When compiling pipelines from 5 games, live_var_analysis takes about a third the time it used to and fossilize-replay is ~1.77% faster. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Reviewed-by: Tony Wasserka <tony.wasserka@gmx.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6733>
This commit is contained in:
@@ -91,18 +91,18 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
|
||||
|
||||
register_demand.resize(block->instructions.size());
|
||||
block->register_demand = RegisterDemand();
|
||||
TempSet live = lives.live_out[block->index];
|
||||
IDSet live = lives.live_out[block->index];
|
||||
|
||||
/* add the live_out_exec to live */
|
||||
bool exec_live = false;
|
||||
if (block->live_out_exec != Temp()) {
|
||||
live.insert(block->live_out_exec);
|
||||
live.insert(block->live_out_exec.id());
|
||||
exec_live = true;
|
||||
}
|
||||
|
||||
/* initialize register demand */
|
||||
for (Temp t : live)
|
||||
new_demand += t;
|
||||
for (unsigned t : live)
|
||||
new_demand += Temp(t, program->temp_rc[t]);
|
||||
new_demand.sgpr -= phi_sgpr_ops[block->index];
|
||||
|
||||
/* traverse the instructions backwards */
|
||||
@@ -126,7 +126,7 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
|
||||
program->needs_vcc = true;
|
||||
|
||||
const Temp temp = definition.getTemp();
|
||||
const size_t n = live.erase(temp);
|
||||
const size_t n = live.erase(temp.id());
|
||||
|
||||
if (n) {
|
||||
new_demand -= temp;
|
||||
@@ -158,7 +158,7 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
|
||||
if (operand.isFixed() && operand.physReg() == vcc)
|
||||
program->needs_vcc = true;
|
||||
const Temp temp = operand.getTemp();
|
||||
const bool inserted = live.insert(temp).second;
|
||||
const bool inserted = live.insert(temp.id()).second;
|
||||
if (inserted) {
|
||||
operand.setFirstKill(true);
|
||||
for (unsigned j = i + 1; j < insn->operands.size(); ++j) {
|
||||
@@ -198,7 +198,7 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
|
||||
if ((definition.isFixed() || definition.hasHint()) && definition.physReg() == vcc)
|
||||
program->needs_vcc = true;
|
||||
const Temp temp = definition.getTemp();
|
||||
const size_t n = live.erase(temp);
|
||||
const size_t n = live.erase(temp.id());
|
||||
|
||||
if (n)
|
||||
definition.setKill(false);
|
||||
@@ -209,12 +209,13 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
|
||||
}
|
||||
|
||||
/* now, we need to merge the live-ins into the live-out sets */
|
||||
for (Temp t : live) {
|
||||
std::vector<unsigned>& preds = t.is_linear() ? block->linear_preds : block->logical_preds;
|
||||
for (unsigned t : live) {
|
||||
RegClass rc = program->temp_rc[t];
|
||||
std::vector<unsigned>& preds = rc.is_linear() ? block->linear_preds : block->logical_preds;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (preds.empty())
|
||||
aco_err(program, "Temporary never defined or are defined after use: %%%d in BB%d", t.id(), block->index);
|
||||
aco_err(program, "Temporary never defined or are defined after use: %%%d in BB%d", t, block->index);
|
||||
#endif
|
||||
|
||||
for (unsigned pred_idx : preds) {
|
||||
@@ -240,7 +241,7 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
|
||||
if (operand.isFixed() && operand.physReg() == vcc)
|
||||
program->needs_vcc = true;
|
||||
/* check if we changed an already processed block */
|
||||
const bool inserted = lives.live_out[preds[i]].insert(operand.getTemp()).second;
|
||||
const bool inserted = lives.live_out[preds[i]].insert(operand.tempId()).second;
|
||||
if (inserted) {
|
||||
operand.setKill(true);
|
||||
worklist.insert(preds[i]);
|
||||
|
||||
Reference in New Issue
Block a user