aco/ra: don't write to exec/ttmp with mulk/addk/cmovk

ttmp sgprs are readonly outside of trap handlers, so the instructions were
probably skipped. RA should also never create additional exec writes.

Fixes: e06773281b ("aco/ra: Optimize some SOP2 instructions with literal to SOPK.")

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32545>
This commit is contained in:
Georg Lehmann
2024-12-09 10:15:38 +01:00
committed by Marge Bot
parent 576a2e798c
commit fe0c72caec
+13 -1
View File
@@ -514,6 +514,17 @@ print_regs(ra_ctx& ctx, PhysRegInterval regs, const RegisterFile& reg_file)
}
}
bool
is_sgpr_writable_without_side_effects(amd_gfx_level gfx_level, PhysReg reg)
{
assert(reg < 256);
bool has_flat_scr_lo_gfx89 = gfx_level >= GFX8 && gfx_level <= GFX9;
bool has_flat_scr_lo_gfx7_or_xnack_mask = gfx_level <= GFX9;
return (reg <= vcc_hi || reg == m0) &&
(!has_flat_scr_lo_gfx89 || (reg != flat_scr_lo && reg != flat_scr_hi)) &&
(!has_flat_scr_lo_gfx7_or_xnack_mask || (reg != 104 || reg != 105));
}
unsigned
get_subdword_operand_stride(amd_gfx_level gfx_level, const aco_ptr<Instruction>& instr,
unsigned idx, RegClass rc)
@@ -2906,7 +2917,8 @@ optimize_encoding_sopk(ra_ctx& ctx, RegisterFile& register_file, aco_ptr<Instruc
return;
unsigned literal_idx = instr->operands[1].isLiteral();
if (instr->operands[!literal_idx].physReg() >= 128)
PhysReg op_reg = instr->operands[!literal_idx].physReg();
if (!is_sgpr_writable_without_side_effects(ctx.program->gfx_level, op_reg))
return;
unsigned def_id = instr->definitions[0].tempId();