From 0812d440c7f6adbfe215f0373e241a7b65469415 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sat, 10 Jul 2021 12:20:56 +0200 Subject: [PATCH] aco: Use std::vector for the underlying container of std::stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, std::stack uses std::deque to allocate its elements, which has poor cache efficiency. std::vector makes appending elements more expensive (due to potential reallocations), but in the changed contexts the element count should always be low anyway. Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_insert_NOPs.cpp | 2 +- src/amd/compiler/aco_insert_waitcnt.cpp | 2 +- src/amd/compiler/aco_instruction_selection.cpp | 2 +- src/amd/compiler/aco_spill.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_insert_NOPs.cpp b/src/amd/compiler/aco_insert_NOPs.cpp index 361411d05e5..5dd1c7183e8 100644 --- a/src/amd/compiler/aco_insert_NOPs.cpp +++ b/src/amd/compiler/aco_insert_NOPs.cpp @@ -847,7 +847,7 @@ void mitigate_hazards(Program* program) { std::vector all_ctx(program->blocks.size()); - std::stack loop_header_indices; + std::stack> loop_header_indices; for (unsigned i = 0; i < program->blocks.size(); i++) { Block& block = program->blocks[i]; diff --git a/src/amd/compiler/aco_insert_waitcnt.cpp b/src/amd/compiler/aco_insert_waitcnt.cpp index d7fc87c126d..cb6c2a60804 100644 --- a/src/amd/compiler/aco_insert_waitcnt.cpp +++ b/src/amd/compiler/aco_insert_waitcnt.cpp @@ -767,7 +767,7 @@ insert_wait_states(Program* program) std::vector in_ctx(program->blocks.size(), wait_ctx(program)); std::vector out_ctx(program->blocks.size(), wait_ctx(program)); - std::stack loop_header_indices; + std::stack> loop_header_indices; unsigned loop_progress = 0; for (unsigned i = 0; i < program->blocks.size();) { diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index bd81c50083c..d4fd9794fdc 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -11811,7 +11811,7 @@ select_gs_copy_shader(Program* program, struct nir_shader* gs_shader, ac_shader_ Temp vtx_offset = bld.vop2(aco_opcode::v_lshlrev_b32, bld.def(v1), Operand::c32(2u), get_arg(&ctx, ctx.args->ac.vertex_id)); - std::stack if_contexts; + std::stack> if_contexts; for (unsigned stream = 0; stream < 4; stream++) { if (stream_id.isConstant() && stream != stream_id.constantValue()) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index dc1d3bc34f7..7dfbc03006b 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -56,7 +56,7 @@ struct spill_ctx { std::vector> spills_entry; std::vector> spills_exit; std::vector processed; - std::stack loop_header; + std::stack> loop_header; std::vector>> next_use_distances_start; std::vector>> next_use_distances_end; std::vector>> interferences;