From b6905438514ae4de0b7f85c861e3d811ddaadda9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 29 Nov 2019 16:47:13 +0100 Subject: [PATCH] aco: fix a couple of value numbering issues Fixes: 3a20ef4a3299fddc886f9d5908d8b3952dd63a54 'aco: refactor value numbering' Reviewed-by: Rhys Perry --- src/amd/compiler/aco_opt_value_numbering.cpp | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/amd/compiler/aco_opt_value_numbering.cpp b/src/amd/compiler/aco_opt_value_numbering.cpp index 6b4eaa8b5f0..708987d4285 100644 --- a/src/amd/compiler/aco_opt_value_numbering.cpp +++ b/src/amd/compiler/aco_opt_value_numbering.cpp @@ -128,8 +128,7 @@ struct InstrPred { /* The results of VOPC depend on the exec mask if used for subgroup operations. */ if ((uint32_t) a->format & (uint32_t) Format::VOPC && a->pass_flags != b->pass_flags) return false; - if (a->format == Format::PSEUDO_BRANCH) - return false; + if (a->isVOP3()) { VOP3A_instruction* a3 = static_cast(a); VOP3A_instruction* b3 = static_cast(b); @@ -145,7 +144,8 @@ struct InstrPred { if (a->isDPP()) { DPP_instruction* aDPP = static_cast(a); DPP_instruction* bDPP = static_cast(b); - return aDPP->dpp_ctrl == bDPP->dpp_ctrl && + return aDPP->pass_flags == bDPP->pass_flags && + aDPP->dpp_ctrl == bDPP->dpp_ctrl && aDPP->bank_mask == bDPP->bank_mask && aDPP->row_mask == bDPP->row_mask && aDPP->bound_ctrl == bDPP->bound_ctrl && @@ -154,6 +154,7 @@ struct InstrPred { aDPP->neg[0] == bDPP->neg[0] && aDPP->neg[1] == bDPP->neg[1]; } + switch (a->format) { case Format::SOPK: { SOPK_instruction* aK = static_cast(a); @@ -186,7 +187,7 @@ struct InstrPred { /* this is fine since they are only used for vertex input fetches */ MTBUF_instruction* aM = static_cast(a); MTBUF_instruction* bM = static_cast(b); - return aM->can_reorder == bM->can_reorder && + return aM->can_reorder && bM->can_reorder && aM->barrier == bM->barrier && aM->dfmt == bM->dfmt && aM->nfmt == bM->nfmt && @@ -203,6 +204,10 @@ struct InstrPred { case Format::FLAT: case Format::GLOBAL: case Format::SCRATCH: + case Format::EXP: + case Format::SOPP: + case Format::PSEUDO_BRANCH: + case Format::PSEUDO_BARRIER: return false; case Format::DS: { if (a->opcode != aco_opcode::ds_bpermute_b32 && @@ -284,6 +289,10 @@ void process_block(vn_ctx& ctx, Block& block) op.setTemp(it->second); } + if (instr->opcode == aco_opcode::p_discard_if || + instr->opcode == aco_opcode::p_demote_to_helper) + ctx.exec_id++; + if (instr->definitions.empty() || instr->opcode == aco_opcode::p_phi || instr->opcode == aco_opcode::p_linear_phi) { new_instructions.emplace_back(std::move(instr)); continue; @@ -296,10 +305,6 @@ void process_block(vn_ctx& ctx, Block& block) ctx.renames[instr->definitions[0].tempId()] = instr->operands[0].getTemp(); } - if (instr->opcode == aco_opcode::p_discard_if || - instr->opcode == aco_opcode::p_demote_to_helper) - ctx.exec_id++; - instr->pass_flags = ctx.exec_id; std::pair res = ctx.expr_values.emplace(instr.get(), block.index); @@ -312,6 +317,7 @@ void process_block(vn_ctx& ctx, Block& block) ctx.program->blocks[res.first->second].fp_mode.canReplace(block.fp_mode)) { for (unsigned i = 0; i < instr->definitions.size(); i++) { assert(instr->definitions[i].regClass() == orig_instr->definitions[i].regClass()); + assert(instr->definitions[i].isTemp()); ctx.renames[instr->definitions[i].tempId()] = orig_instr->definitions[i].getTemp(); } } else { @@ -358,8 +364,8 @@ void value_numbering(Program* program) if (block.kind & block_kind_merge) { ctx.exec_id--; } else if (block.kind & block_kind_loop_exit) { - ctx.exec_id -= program->blocks[loop_headers.back()].logical_preds.size(); - ctx.exec_id -= block.logical_preds.size(); + ctx.exec_id -= program->blocks[loop_headers.back()].linear_preds.size(); + ctx.exec_id -= block.linear_preds.size(); loop_headers.pop_back(); } @@ -372,7 +378,8 @@ void value_numbering(Program* program) if (block.kind & block_kind_branch || block.kind & block_kind_loop_preheader || block.kind & block_kind_break || - block.kind & block_kind_continue) + block.kind & block_kind_continue || + block.kind & block_kind_discard) ctx.exec_id++; else if (block.kind & block_kind_continue_or_break) ctx.exec_id += 2; -- 2.30.2