Skip to content

Commit

Permalink
JIT: Allow spill-at-single-def for pure defs (#85251)
Browse files Browse the repository at this point in the history
Allow the spill-at-single-def logic to kick in for defs without subsequent uses before the spill.
  • Loading branch information
jakobbotsch authored Apr 25, 2023
1 parent aa42cc0 commit 4e2228e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3423,15 +3423,11 @@ void LinearScan::spillInterval(Interval* interval, RefPosition* fromRefPosition
}
}

// Only handle the singledef intervals whose firstRefPosition is RefTypeDef and is not yet marked as spillAfter.
// The singledef intervals whose firstRefPositions are already marked as spillAfter, no need to mark them as
// singleDefSpill because they will always get spilled at firstRefPosition.
// This helps in spilling the singleDef at definition
// Only handle the singledef intervals whose firstRefPosition is RefTypeDef.
//
// Note: Only mark "singleDefSpill" for those intervals who ever get spilled. The intervals that are never spilled
// will not be marked as "singleDefSpill" and hence won't get spilled at the first definition.
if (interval->isSingleDef && RefTypeIsDef(interval->firstRefPosition->refType) &&
!interval->firstRefPosition->spillAfter)
if (interval->isSingleDef && RefTypeIsDef(interval->firstRefPosition->refType))
{
// TODO-CQ: Check if it is beneficial to spill at def, meaning, if it is a hot block don't worry about
// doing the spill. Another option is to track number of refpositions and a interval has more than X
Expand Down Expand Up @@ -6280,6 +6276,11 @@ void LinearScan::resolveLocalRef(BasicBlock* block, GenTreeLclVar* treeNode, Ref
varDsc->SetRegNum(REG_STK);
interval->physReg = REG_NA;
writeLocalReg(treeNode->AsLclVar(), interval->varNum, REG_NA);

if (currentRefPosition->singleDefSpill)
{
varDsc->lvSpillAtSingleDef = true;
}
}
else // Not reload and Not pure-def that's spillAfter
{
Expand Down

0 comments on commit 4e2228e

Please sign in to comment.