Mesa (main): aco/spill: Avoid destroying local next use maps over-eagerly

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 1 09:57:11 UTC 2021


Module: Mesa
Branch: main
Commit: 92d7a6ab1c2f812f1b00ecad313ea1edc4fe7e53
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=92d7a6ab1c2f812f1b00ecad313ea1edc4fe7e53

Author: Tony Wasserka <tony.wasserka at gmx.de>
Date:   Mon Jul 19 19:43:54 2021 +0200

aco/spill: Avoid destroying local next use maps over-eagerly

Recreating these maps in a later block requires allocating fresh memory.
Instead, by never shrinking the containing vector in the first place,
previously allocated map memory is now re-used.

Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11925>

---

 src/amd/compiler/aco_spill.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp
index 1965b53f4f7..c9b758eb0bd 100644
--- a/src/amd/compiler/aco_spill.cpp
+++ b/src/amd/compiler/aco_spill.cpp
@@ -360,7 +360,11 @@ void
 update_local_next_uses(spill_ctx& ctx, Block* block,
                 std::vector<std::map<Temp, uint32_t>>& local_next_uses)
 {
-   local_next_uses.resize(block->instructions.size());
+   if (local_next_uses.size() < block->instructions.size()) {
+      /* Allocate more next-use-maps. Note that by never reducing the vector size, we enable
+       * future calls to this function to re-use already allocated map memory. */
+      local_next_uses.resize(block->instructions.size());
+   }
 
    local_next_uses[block->instructions.size() - 1].clear();
    for (std::pair<const Temp, std::pair<uint32_t, uint32_t>>& pair :



More information about the mesa-commit mailing list