diff --git a/src/amd/compiler/aco_opt_value_numbering.cpp b/src/amd/compiler/aco_opt_value_numbering.cpp index 5fa61e72bb4..45d9847ac00 100644 --- a/src/amd/compiler/aco_opt_value_numbering.cpp +++ b/src/amd/compiler/aco_opt_value_numbering.cpp @@ -239,6 +239,7 @@ struct vn_ctx { monotonic_buffer_resource m; expr_set expr_values; aco::unordered_map renames; + std::vector uses; /* The exec id should be the same on the same level of control flow depth. * Together with the check for dominator relations, it is safe to assume @@ -254,6 +255,7 @@ struct vn_ctx { for (Block& block : program->blocks) size += block.instructions.size(); expr_values.reserve(size); + uses = dead_code_analysis(program); } }; @@ -342,6 +344,10 @@ process_block(vn_ctx& ctx, Block& block) new_instructions.reserve(block.instructions.size()); for (aco_ptr& instr : block.instructions) { + /* Clean up dead create_vector/split_vector left behind by instruction selection. */ + if (is_dead(ctx.uses, instr.get())) + continue; + /* first, rename operands */ for (Operand& op : instr->operands) { if (!op.isTemp())