Skip to content

JIT: Propagate multi-reg-index for upper-vector-restore ref positions #88380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/coreclr/jit/lsra.h
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,8 @@ class LinearScan : public LinearScanInterface

#if FEATURE_PARTIAL_SIMD_CALLEE_SAVE
void buildUpperVectorSaveRefPositions(GenTree* tree, LsraLocation currentLoc, regMaskTP fpCalleeKillSet);
void buildUpperVectorRestoreRefPosition(Interval* lclVarInterval,
LsraLocation currentLoc,
GenTree* node,
bool isUse);
void buildUpperVectorRestoreRefPosition(
Interval* lclVarInterval, LsraLocation currentLoc, GenTree* node, bool isUse, unsigned multiRegIdx);
#endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE

#if defined(UNIX_AMD64_ABI) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
Expand Down
15 changes: 8 additions & 7 deletions src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,11 +1596,10 @@ void LinearScan::buildUpperVectorSaveRefPositions(GenTree* tree, LsraLocation cu
// If null, the restore will be inserted at the end of the block.
// isUse - If the refPosition that is about to be created represents a use or not.
// - If not, it would be the one at the end of the block.
// multiRegIdx - Register position if this restore corresponds to a field of a multi reg node.
//
void LinearScan::buildUpperVectorRestoreRefPosition(Interval* lclVarInterval,
LsraLocation currentLoc,
GenTree* node,
bool isUse)
void LinearScan::buildUpperVectorRestoreRefPosition(
Interval* lclVarInterval, LsraLocation currentLoc, GenTree* node, bool isUse, unsigned multiRegIdx)
{
if (lclVarInterval->isPartiallySpilled)
{
Expand All @@ -1611,6 +1610,8 @@ void LinearScan::buildUpperVectorRestoreRefPosition(Interval* lclVarInterval,
newRefPosition(upperVectorInterval, currentLoc, RefTypeUpperVectorRestore, node, RBM_NONE);
lclVarInterval->isPartiallySpilled = false;

restorePos->setMultiRegIdx(multiRegIdx);

if (isUse)
{
// If there was a use of the restore before end of the block restore,
Expand Down Expand Up @@ -2536,7 +2537,7 @@ void LinearScan::buildIntervals()
while (largeVectorVarsIter.NextElem(&largeVectorVarIndex))
{
Interval* lclVarInterval = getIntervalForLocalVar(largeVectorVarIndex);
buildUpperVectorRestoreRefPosition(lclVarInterval, currentLoc, nullptr, false);
buildUpperVectorRestoreRefPosition(lclVarInterval, currentLoc, nullptr, false, 0);
}
#endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE

Expand Down Expand Up @@ -3195,7 +3196,7 @@ RefPosition* LinearScan::BuildUse(GenTree* operand, regMaskTP candidates, int mu
UpdatePreferencesOfDyingLocal(interval);
}
#if FEATURE_PARTIAL_SIMD_CALLEE_SAVE
buildUpperVectorRestoreRefPosition(interval, currentLoc, operand, true);
buildUpperVectorRestoreRefPosition(interval, currentLoc, operand, true, (unsigned)multiRegIdx);
#endif
}
else if (operand->IsMultiRegLclVar())
Expand All @@ -3209,7 +3210,7 @@ RefPosition* LinearScan::BuildUse(GenTree* operand, regMaskTP candidates, int mu
VarSetOps::RemoveElemD(compiler, currentLiveVars, fieldVarDsc->lvVarIndex);
}
#if FEATURE_PARTIAL_SIMD_CALLEE_SAVE
buildUpperVectorRestoreRefPosition(interval, currentLoc, operand, true);
buildUpperVectorRestoreRefPosition(interval, currentLoc, operand, true, (unsigned)multiRegIdx);
#endif
}
else
Expand Down