Skip to content

Reserve return reg for cross-reg-file copy #37863

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 1 commit into from
Jun 16, 2020
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
32 changes: 30 additions & 2 deletions src/coreclr/src/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3485,12 +3485,36 @@ int LinearScan::BuildReturn(GenTree* tree)
retTypeDesc.GetReturnRegCount());
}
srcCount = pRetTypeDesc->GetReturnRegCount();
// For any source that's coming from a different register file, we need to ensure that
// we reserve the specific ABI register we need.
bool hasMismatchedRegTypes = false;
if (op1->IsMultiRegLclVar())
{
for (int i = 0; i < srcCount; i++)
{
RegisterType srcType = regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i));
RegisterType dstType = regType(pRetTypeDesc->GetReturnRegType(i));
if (srcType != dstType)
{
hasMismatchedRegTypes = true;
regMaskTP dstRegMask = genRegMask(pRetTypeDesc->GetABIReturnReg(i));
if (varTypeIsFloating(dstType))
{
buildInternalFloatRegisterDefForNode(tree, dstRegMask);
}
else
{
buildInternalIntRegisterDefForNode(tree, dstRegMask);
}
}
}
}
for (int i = 0; i < srcCount; i++)
{
// We will build uses of the type of the operand registers/fields, and the codegen
// for return will move as needed.
if (!op1->OperIs(GT_LCL_VAR) || (regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)) ==
regType(pRetTypeDesc->GetReturnRegType(i))))
if (!hasMismatchedRegTypes || (regType(op1->AsLclVar()->GetFieldTypeByIndex(compiler, i)) ==
regType(pRetTypeDesc->GetReturnRegType(i))))
{
BuildUse(op1, genRegMask(pRetTypeDesc->GetABIReturnReg(i)), i);
}
Expand All @@ -3499,6 +3523,10 @@ int LinearScan::BuildReturn(GenTree* tree)
BuildUse(op1, RBM_NONE, i);
}
}
if (hasMismatchedRegTypes)
{
buildInternalRegisterUses();
}
return srcCount;
}
}
Expand Down