From: Daniel Schürmann Date: Wed, 30 Oct 2019 13:54:44 +0000 (+0100) Subject: aco: omit linear VGPRs as spill variables X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0de16b7de051be460fe1f70c7ede42f1fdb005b;p=mesa.git aco: omit linear VGPRs as spill variables Reviewed-by: Rhys Perry --- diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index 0d6ea9271e4..977f4583bd8 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -157,6 +157,8 @@ void next_uses_per_block(spill_ctx& ctx, unsigned block_idx, std::set& /* omit exec mask */ if (op.isFixed() && op.physReg() == exec) continue; + if (op.regClass().type() == RegType::vgpr && op.regClass().is_linear()) + continue; if (op.isTemp()) next_uses[op.getTemp()] = {block_idx, idx}; } @@ -322,6 +324,8 @@ std::vector> local_next_uses(spill_ctx& ctx, Block* blo for (const Operand& op : instr->operands) { if (op.isFixed() && op.physReg() == exec) continue; + if (op.regClass().type() == RegType::vgpr && op.regClass().is_linear()) + continue; if (op.isTemp()) next_uses[op.getTemp()] = idx; } @@ -520,7 +524,7 @@ RegisterDemand init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_id /* keep variables spilled on all incoming paths */ for (std::pair> pair : ctx.next_use_distances_start[block_idx]) { - std::vector& preds = pair.first.type() == RegType::vgpr ? block->logical_preds : block->linear_preds; + std::vector& preds = pair.first.is_linear() ? block->linear_preds : block->logical_preds; /* If it can be rematerialized, keep the variable spilled if all predecessors do not reload it. * Otherwise, if any predecessor reloads it, ensure it's reloaded on all other predecessors. * The idea is that it's better in practice to rematerialize redundantly than to create lots of phis. */ @@ -803,7 +807,7 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx) /* iterate all (other) spilled variables for which to spill at the predecessor */ // TODO: would be better to have them sorted: first vgprs and first with longest distance for (std::pair pair : ctx.spills_entry[block_idx]) { - std::vector preds = pair.first.type() == RegType::vgpr ? block->logical_preds : block->linear_preds; + std::vector preds = pair.first.is_linear() ? block->linear_preds : block->logical_preds; for (unsigned pred_idx : preds) { /* variable is already spilled at predecessor */ @@ -896,7 +900,7 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx) /* skip spilled variables */ if (ctx.spills_entry[block_idx].find(pair.first) != ctx.spills_entry[block_idx].end()) continue; - std::vector preds = pair.first.type() == RegType::vgpr ? block->logical_preds : block->linear_preds; + std::vector preds = pair.first.is_linear() ? block->linear_preds : block->logical_preds; /* variable is dead at predecessor, it must be from a phi */ bool is_dead = false; @@ -950,7 +954,7 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx) if (!is_same) { /* the variable was renamed differently in the predecessors: we have to create a phi */ - aco_opcode opcode = pair.first.type() == RegType::vgpr ? aco_opcode::p_phi : aco_opcode::p_linear_phi; + aco_opcode opcode = pair.first.is_linear() ? aco_opcode::p_linear_phi : aco_opcode::p_phi; aco_ptr phi{create_instruction(opcode, Format::PSEUDO, preds.size(), 1)}; rename = {ctx.program->allocateId(), pair.first.regClass()}; for (unsigned i = 0; i < phi->operands.size(); i++) {