diff --git a/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.cpp b/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.cpp index 3b55fa2eff..52b4cf1696 100644 --- a/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.cpp +++ b/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.cpp @@ -144,7 +144,7 @@ RegAlloc::ArgumentInfo RegAlloc::GetArgumentInfo(IR::Inst* inst) { } bool RegAlloc::WasValueDefined(IR::Inst* inst) const { - return defined_insts_count > 0; + return defined_insts.count(inst) > 0; } void RegAlloc::PrepareForCall(std::optional arg0, std::optional arg1, std::optional arg2, std::optional arg3) { @@ -192,8 +192,7 @@ void RegAlloc::PrepareForCall(std::optional arg0, } void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) { - ++defined_insts_count; - + defined_insts.insert(inst); ASSERT(!ValueLocation(inst)); if (arg.value.IsImmediate()) { @@ -207,8 +206,7 @@ void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) { } void RegAlloc::DefineAsRegister(IR::Inst* inst, oaknut::Reg reg) { - ++defined_insts_count; - + defined_insts.insert(inst); ASSERT(!ValueLocation(inst)); auto& info = reg.is_vector() ? fprs[reg.index()] : gprs[reg.index()]; ASSERT(info.IsCompletelyEmpty()); @@ -374,8 +372,7 @@ int RegAlloc::RealizeReadImpl(const IR::Value& value) { template int RegAlloc::RealizeWriteImpl(const IR::Inst* value) { - ++defined_insts_count; - + defined_insts.insert(inst); ASSERT(!ValueLocation(value)); if constexpr (kind == HostLoc::Kind::Gpr) { @@ -399,8 +396,7 @@ int RegAlloc::RealizeWriteImpl(const IR::Inst* value) { template int RegAlloc::RealizeReadWriteImpl(const IR::Value& read_value, const IR::Inst* write_value) { - ++defined_insts_count; - + defined_insts.insert(inst); // TODO: Move elimination const int write_loc = RealizeWriteImpl(write_value); @@ -463,8 +459,7 @@ void RegAlloc::SpillFpr(int index) { } void RegAlloc::ReadWriteFlags(Argument& read, IR::Inst* write) { - ++defined_insts_count; - + defined_insts.insert(inst); const auto current_location = ValueLocation(read.value.GetInst()); ASSERT(current_location); diff --git a/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.h b/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.h index ea47f1c897..ee93f13cfc 100644 --- a/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.h +++ b/src/dynarmic/src/dynarmic/backend/arm64/reg_alloc.h @@ -332,8 +332,7 @@ private: std::array spills; mutable std::mt19937 rand_gen; - - size_t defined_insts_count = 0; + ankerl::unordered_dense::set defined_insts; }; template