From 8657eede8aec88537d64bbd86e1401018992acf1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 11 Nov 2019 16:21:51 +0100 Subject: [PATCH] aco: check if SALU instructions are predeceeded by exec when calculating WQM needs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-By: Timur Kristóf Reviewed-by: Rhys Perry --- src/amd/compiler/aco_insert_NOPs.cpp | 9 +-------- src/amd/compiler/aco_insert_exec_mask.cpp | 5 +++-- src/amd/compiler/aco_ir.h | 9 +++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/amd/compiler/aco_insert_NOPs.cpp b/src/amd/compiler/aco_insert_NOPs.cpp index 2c69407b808..b0404300e0e 100644 --- a/src/amd/compiler/aco_insert_NOPs.cpp +++ b/src/amd/compiler/aco_insert_NOPs.cpp @@ -115,13 +115,6 @@ bool VALU_writes_sgpr(aco_ptr& instr) return false; } -bool instr_reads_exec(const aco_ptr& instr) -{ - return std::any_of(instr->operands.begin(), instr->operands.end(), [](const Operand &op) -> bool { - return op.physReg() == exec_lo || op.physReg() == exec_hi; - }); -} - bool instr_writes_exec(const aco_ptr& instr) { return std::any_of(instr->definitions.begin(), instr->definitions.end(), [](const Definition &def) -> bool { @@ -445,7 +438,7 @@ void handle_instruction_gfx10(NOP_ctx_gfx10 &ctx, aco_ptr& instr, /* VcmpxExecWARHazard * Handle any VALU instruction writing the exec mask after it was read by a non-VALU instruction. */ - if (!instr->isVALU() && instr_reads_exec(instr)) { + if (!instr->isVALU() && instr->reads_exec()) { ctx.has_nonVALU_exec_read = true; } else if (instr->isVALU()) { if (instr_writes_exec(instr)) { diff --git a/src/amd/compiler/aco_insert_exec_mask.cpp b/src/amd/compiler/aco_insert_exec_mask.cpp index 530faab2167..c2693608a1a 100644 --- a/src/amd/compiler/aco_insert_exec_mask.cpp +++ b/src/amd/compiler/aco_insert_exec_mask.cpp @@ -95,6 +95,8 @@ struct exec_ctx { }; bool pred_by_exec_mask(aco_ptr& instr) { + if (instr->isSALU()) + return instr->reads_exec(); if (instr->format == Format::SMEM || instr->isSALU()) return false; if (instr->format == Format::PSEUDO_BARRIER) @@ -200,8 +202,7 @@ void get_block_needs(wqm_ctx &ctx, exec_ctx &exec_ctx, Block* block) ctx.wqm = false; } - for (int i = block->instructions.size() - 1; i >= 0; --i) - { + for (int i = block->instructions.size() - 1; i >= 0; --i) { aco_ptr& instr = block->instructions[i]; WQMState needs = needs_exact(instr) ? Exact : Unspecified; diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 5b708c884e6..a6fe846c74d 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -616,6 +616,15 @@ struct Instruction { } constexpr bool usesModifiers() const noexcept; + + constexpr bool reads_exec() const noexcept + { + for (const Operand& op : operands) { + if (op.isFixed() && op.physReg() == exec) + return true; + } + return false; + } }; struct SOPK_instruction : public Instruction { -- 2.30.2