aco/ra: create M0-affinities for s_sendmsg

v2 by Timur Kristóf:
Do not add the affinity for instructions that can't write m0
reliably, such as readlane-like instructions on GFX8.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22690>
This commit is contained in:
Rhys Perry
2023-04-27 16:22:52 +01:00
committed by Marge Bot
parent 9dd6fcd9ec
commit d5398b62da
3 changed files with 30 additions and 0 deletions
+21
View File
@@ -479,6 +479,27 @@ can_use_opsel(amd_gfx_level gfx_level, aco_opcode op, int idx)
}
}
bool
can_write_m0(amd_gfx_level gfx_level, const aco_ptr<Instruction>& instr)
{
if (instr->isSALU())
return true;
if (instr->isVALU())
return gfx_level >= GFX9;
switch (instr->opcode) {
case aco_opcode::p_parallelcopy:
case aco_opcode::p_extract:
case aco_opcode::p_insert:
return true;
case aco_opcode::p_reload:
return gfx_level >= GFX9;
default:
return false;
}
}
bool
instr_is_16bit(amd_gfx_level gfx_level, aco_opcode op)
{
+1
View File
@@ -1804,6 +1804,7 @@ bool instr_is_16bit(amd_gfx_level gfx_level, aco_opcode op);
uint8_t get_gfx11_true16_mask(aco_opcode op);
bool can_use_SDWA(amd_gfx_level gfx_level, const aco_ptr<Instruction>& instr, bool pre_ra);
bool can_use_DPP(const aco_ptr<Instruction>& instr, bool pre_ra, bool dpp8);
bool can_write_m0(amd_gfx_level gfx_level, const aco_ptr<Instruction>& instr);
/* updates "instr" and returns the old instruction (or NULL if no update was needed) */
aco_ptr<Instruction> convert_to_SDWA(amd_gfx_level gfx_level, aco_ptr<Instruction>& instr);
aco_ptr<Instruction> convert_to_DPP(aco_ptr<Instruction>& instr, bool dpp8);
@@ -55,6 +55,7 @@ struct assignment {
struct {
bool assigned : 1;
bool vcc : 1;
bool m0 : 1;
};
uint8_t _ = 0;
};
@@ -1653,6 +1654,11 @@ get_reg(ra_ctx& ctx, RegisterFile& reg_file, Temp temp,
if (get_reg_specified(ctx, reg_file, temp.regClass(), instr, vcc))
return vcc;
}
if (ctx.assignments[temp.id()].m0) {
if (get_reg_specified(ctx, reg_file, temp.regClass(), instr, m0) &&
can_write_m0(ctx.program->gfx_level, instr))
return m0;
}
std::optional<PhysReg> res;
@@ -2461,6 +2467,8 @@ get_affinities(ra_ctx& ctx, std::vector<IDSet>& live_out_per_block)
if (!instr->definitions[1].isKill() && instr->operands[0].isTemp() &&
instr->operands[1].isFixed() && instr->operands[1].physReg() == exec)
ctx.assignments[instr->operands[0].tempId()].vcc = true;
} else if (instr->opcode == aco_opcode::s_sendmsg) {
ctx.assignments[instr->operands[0].tempId()].m0 = true;
}
/* add operands to live variables */