Skip to content

Commit

Permalink
Consider reloadWeight while evaluating spill cost
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalspathak committed Jun 9, 2021
1 parent 3d13204 commit 0a29ac7
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11258,13 +11258,31 @@ void LinearScan::RegisterSelection::try_SPILL_COST()
continue;
}

float currentSpillWeight = linearScan->spillCost[spillCandidateRegNum];
#ifdef TARGET_ARM
if (currentInterval->registerType == TYP_DOUBLE)
float currentSpillWeight = 0;
RefPosition* recentRefPosition = spillCandidateRegRecord->assignedInterval->recentRefPosition;
if ((recentRefPosition != nullptr) && (recentRefPosition->RegOptional()) &&
!(currentInterval->isLocalVar && recentRefPosition->IsActualRef()))
{
currentSpillWeight = max(currentSpillWeight, linearScan->spillCost[REG_NEXT(spillCandidateRegNum)]);
// 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.
// For such cases, consider the spill cost of next refposition.
RefPosition* reloadRefPosition = spillCandidateRegRecord->assignedInterval->getNextRefPosition();
if (reloadRefPosition != nullptr)
{
currentSpillWeight = linearScan->getWeight(reloadRefPosition);
}
}
else
{
currentSpillWeight = linearScan->spillCost[spillCandidateRegNum];
#ifdef TARGET_ARM
if (currentInterval->registerType == TYP_DOUBLE)
{
currentSpillWeight = max(currentSpillWeight, linearScan->spillCost[REG_NEXT(spillCandidateRegNum)]);
}
#endif
}

if (currentSpillWeight < bestSpillWeight)
{
bestSpillWeight = currentSpillWeight;
Expand Down

0 comments on commit 0a29ac7

Please sign in to comment.