Skip to content
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

JIT: Unify and clean up unspilling #91663

Merged
merged 2 commits into from
Sep 28, 2023
Merged
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
30 changes: 6 additions & 24 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,13 +1211,8 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree)
// Reset spilled flag, since we are going to load a local variable from its home location.
unspillTree->gtFlags &= ~GTF_SPILLED;

GenTreeLclVar* lcl = unspillTree->AsLclVar();
LclVarDsc* varDsc = compiler->lvaGetDesc(lcl);
var_types unspillType = varDsc->GetRegisterType(lcl);
assert(unspillType != TYP_UNDEF);

// TODO-Cleanup: The following code could probably be further merged and cleaned up.
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
GenTreeLclVar* lcl = unspillTree->AsLclVar();
LclVarDsc* varDsc = compiler->lvaGetDesc(lcl);

// Pick type to reload register from stack with. Note that in
// general, the type of 'lcl' does not have any relation to the
Expand All @@ -1241,19 +1236,11 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree)
// relies on the normalization to have happened here as part of
// unspilling.
//
if (varDsc->lvNormalizeOnLoad())
var_types unspillType = varDsc->lvNormalizeOnLoad() ? varDsc->TypeGet() : varDsc->GetStackSlotHomeType();

if (varTypeIsGC(lcl))
{
unspillType = varDsc->TypeGet();
}
else
{
// Potentially narrower -- see if we should widen.
var_types lclLoadType = varDsc->GetStackSlotHomeType();
assert(lclLoadType != TYP_UNDEF);
if (genTypeSize(unspillType) < genTypeSize(lclLoadType))
{
unspillType = lclLoadType;
}
unspillType = lcl->TypeGet();
}

#if defined(TARGET_LOONGARCH64)
Expand All @@ -1262,11 +1249,6 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree)
unspillType = unspillType == TYP_FLOAT ? TYP_INT : TYP_LONG;
}
#endif
#elif defined(TARGET_ARM)
// No normalizing for ARM
#else
NYI("Unspilling not implemented for this target architecture.");
#endif

bool reSpill = ((unspillTree->gtFlags & GTF_SPILL) != 0);
bool isLastUse = lcl->IsLastUse(0);
Expand Down
Loading