From a1022dbf07c360abdd2f1d98158f4a9e4ddee59e Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 25 Aug 2022 20:07:41 +0100 Subject: [PATCH] aco: use some helpers in GFX10 hazard workarounds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit No fossil-db changes. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_insert_NOPs.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/amd/compiler/aco_insert_NOPs.cpp b/src/amd/compiler/aco_insert_NOPs.cpp index b63f275..a932efe 100644 --- a/src/amd/compiler/aco_insert_NOPs.cpp +++ b/src/amd/compiler/aco_insert_NOPs.cpp @@ -693,11 +693,7 @@ handle_instruction_gfx10(State& state, NOP_ctx_gfx10& ctx, aco_ptr& ctx.sgprs_read_by_VMEM_store.reset(); /* Insert s_waitcnt_depctr instruction with magic imm to mitigate the problem */ - aco_ptr depctr{ - create_instruction(aco_opcode::s_waitcnt_depctr, Format::SOPP, 0, 0)}; - depctr->imm = 0xffe3; - depctr->block = -1; - new_instructions.emplace_back(std::move(depctr)); + bld.sopp(aco_opcode::s_waitcnt_depctr, -1, 0xffe3); } } else if (instr->isVALU()) { /* Hazard is mitigated by any VALU instruction */ @@ -717,11 +713,8 @@ handle_instruction_gfx10(State& state, NOP_ctx_gfx10& ctx, aco_ptr& ctx.has_VOPC_write_exec = false; /* v_nop would be discarded by SQ, so use v_mov with the first operand of the permlane */ - aco_ptr v_mov{ - create_instruction(aco_opcode::v_mov_b32, Format::VOP1, 1, 1)}; - v_mov->definitions[0] = Definition(instr->operands[0].physReg(), v1); - v_mov->operands[0] = Operand(instr->operands[0].physReg(), v1); - new_instructions.emplace_back(std::move(v_mov)); + bld.vop1(aco_opcode::v_mov_b32, Definition(instr->operands[0].physReg(), v1), + Operand(instr->operands[0].physReg(), v1)); } else if (instr->isVALU() && instr->opcode != aco_opcode::v_nop) { ctx.has_VOPC_write_exec = false; } @@ -736,11 +729,7 @@ handle_instruction_gfx10(State& state, NOP_ctx_gfx10& ctx, aco_ptr& ctx.has_nonVALU_exec_read = false; /* Insert s_waitcnt_depctr instruction with magic imm to mitigate the problem */ - aco_ptr depctr{ - create_instruction(aco_opcode::s_waitcnt_depctr, Format::SOPP, 0, 0)}; - depctr->imm = 0xfffe; - depctr->block = -1; - new_instructions.emplace_back(std::move(depctr)); + bld.sopp(aco_opcode::s_waitcnt_depctr, -1, 0xfffe); } else if (instr_writes_sgpr(instr)) { /* Any VALU instruction that writes an SGPR mitigates the problem */ ctx.has_nonVALU_exec_read = false; @@ -763,11 +752,7 @@ handle_instruction_gfx10(State& state, NOP_ctx_gfx10& ctx, aco_ptr& ctx.sgprs_read_by_SMEM.reset(); /* Insert s_mov to mitigate the problem */ - aco_ptr s_mov{ - create_instruction(aco_opcode::s_mov_b32, Format::SOP1, 1, 1)}; - s_mov->definitions[0] = Definition(sgpr_null, s1); - s_mov->operands[0] = Operand::zero(); - new_instructions.emplace_back(std::move(s_mov)); + bld.sop1(aco_opcode::s_mov_b32, Definition(sgpr_null, s1), Operand::zero()); } } else if (instr->isSALU()) { if (instr->format != Format::SOPP) { @@ -780,8 +765,8 @@ handle_instruction_gfx10(State& state, NOP_ctx_gfx10& ctx, aco_ptr& if (sopp.imm == 0 && sopp.definitions[0].physReg() == sgpr_null) ctx.sgprs_read_by_SMEM.reset(); } else if (sopp.opcode == aco_opcode::s_waitcnt) { - unsigned lgkm = (sopp.imm >> 8) & 0x3f; - if (lgkm == 0) + wait_imm imm(state.program->gfx_level, instr->sopp().imm); + if (imm.lgkm == 0) ctx.sgprs_read_by_SMEM.reset(); } } -- 2.7.4