diff --git a/.pick_status.json b/.pick_status.json index ed59eba0199..bd00c0b978a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4374,7 +4374,7 @@ "description": "aco: perform dce for blocks skipped for process_block()", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "9e8ba10447f08ee757f6a4719ff23960a2b18c6b", "notes": null diff --git a/src/amd/compiler/aco_opt_value_numbering.cpp b/src/amd/compiler/aco_opt_value_numbering.cpp index dfd8c1e3891..9f867e2e0af 100644 --- a/src/amd/compiler/aco_opt_value_numbering.cpp +++ b/src/amd/compiler/aco_opt_value_numbering.cpp @@ -427,6 +427,21 @@ process_block(vn_ctx& ctx, Block& block) block.instructions = std::move(new_instructions); } +void +dce_instructions(vn_ctx& ctx, Block& block) +{ + std::vector> new_instructions; + new_instructions.reserve(block.instructions.size()); + + for (aco_ptr& instr : block.instructions) { + if (is_dead(ctx.uses, instr.get())) + continue; + new_instructions.emplace_back(std::move(instr)); + } + + block.instructions = std::move(new_instructions); +} + void rename_phi_operands(Block& block, aco::unordered_map& renames) { @@ -467,10 +482,12 @@ value_numbering(Program* program) if (block.logical_idom == (int)block.index) ctx.expr_values.clear(); - if (block.logical_idom != -1) + if (block.logical_idom != -1) { process_block(ctx, block); - else + } else { + dce_instructions(ctx, block); rename_phi_operands(block, ctx.renames); + } /* increment exec_id when entering nested control flow */ if (block.kind & block_kind_branch || block.kind & block_kind_loop_preheader ||