From 1553ddd0146ed7e1f56bdcdfb82707e3e4ac03ff Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 28 Oct 2025 20:21:38 +0000 Subject: [PATCH] fuck reg pressure Signed-off-by: lizzie --- .../src/dynarmic/backend/x64/reg_alloc.cpp | 22 +++++++++---------- .../src/dynarmic/backend/x64/reg_alloc.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp b/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp index 2db817a90f..4265de2b11 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.cpp @@ -444,18 +444,18 @@ HostLoc RegAlloc::SelectARegister(const boost::container::static_vector= HostLoc::R8 && *it <= HostLoc::R15) { - it_rex_candidate = it; - } else { - it_candidate = it; - } - if (min_lru_counter == 0) - break; //early exit + } else if (loc_info.lru_counter < min_lru_counter) { + // Otherwise a "quasi"-LRU + min_lru_counter = loc_info.lru_counter; + if (*it >= HostLoc::R8 && *it <= HostLoc::R15) { + it_rex_candidate = it; + } else { + it_candidate = it; } + // There used to be a break here - DO NOT BREAK away you MUST + // evaluate ALL of the registers BEFORE making a decision on when to take + // otherwise reg pressure will get high and bugs will seep :) + // TODO(lizzie): Investigate these god awful annoying reg pressure issues } } // Final resolution goes as follows: diff --git a/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.h b/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.h index 2bd274730a..0e9e465774 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.h +++ b/src/dynarmic/src/dynarmic/backend/x64/reg_alloc.h @@ -94,8 +94,8 @@ private: uint16_t is_being_used_count = 0; //8 uint16_t current_references = 0; //8 // Value state - uint8_t max_bit_width : 4 = 0; //Valid values: log2(1,2,4,8,16,32,128) = (0, 1, 2, 3, 4, 5, 6) uint8_t lru_counter : 2 = 0; //1 + uint8_t max_bit_width : 4 = 0; //Valid values: log2(1,2,4,8,16,32,128) = (0, 1, 2, 3, 4, 5, 6) bool is_scratch : 1 = false; //1 bool is_set_last_use : 1 = false; //1 friend class RegAlloc;