From 7295b01e7933121221aff801a1bdac58366af7e4 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Tue, 6 Jul 2021 15:36:01 -0700 Subject: [PATCH] fix spill cost calculation --- src/coreclr/jit/lsra.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/jit/lsra.cpp b/src/coreclr/jit/lsra.cpp index 86d037e12ac5f6..c1f4f9dd13c1f5 100644 --- a/src/coreclr/jit/lsra.cpp +++ b/src/coreclr/jit/lsra.cpp @@ -11264,8 +11264,8 @@ void LinearScan::RegisterSelection::try_SPILL_COST() RefPosition* recentRefPosition = spillCandidateRegRecord->assignedInterval != nullptr ? spillCandidateRegRecord->assignedInterval->recentRefPosition : nullptr; - if ((recentRefPosition != nullptr) && (recentRefPosition->RegOptional()) && - !(currentInterval->isLocalVar && recentRefPosition->IsActualRef())) + if ((recentRefPosition != nullptr) && (recentRefPosition->RegOptional() && + !(spillCandidateRegRecord->assignedInterval->isLocalVar && recentRefPosition->IsActualRef()))) { // We do not "spillAfter" if previous (recent) refPosition was regOptional or if it // is not an actual ref. In those cases, we will reload in future (next) refPosition.