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

Enreg structs x86 windows. #55535

Merged
merged 2 commits into from
Jul 13, 2021
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
1 change: 1 addition & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -6801,6 +6801,7 @@ struct GenTreeCopyOrReload : public GenTreeUnOp

GenTreeCopyOrReload(genTreeOps oper, var_types type, GenTree* op1) : GenTreeUnOp(oper, type, op1)
{
assert(type != TYP_STRUCT || op1->IsMultiRegNode());
SetRegNum(REG_NA);
ClearOtherRegs();
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ CONFIG_INTEGER(JitSaveFpLrWithCalleeSavedRegisters, W("JitSaveFpLrWithCalleeSave
#endif // defined(TARGET_ARM64)
#endif // DEBUG

#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS)
#if defined(TARGET_WINDOWS) && defined(TARGET_XARCH)
CONFIG_INTEGER(JitEnregStructLocals, W("JitEnregStructLocals"), 1) // Allow to enregister locals with struct type.
#else
CONFIG_INTEGER(JitEnregStructLocals, W("JitEnregStructLocals"), 0) // Don't allow to enregister locals with struct type
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3497,6 +3497,10 @@ void Compiler::lvaSortByRefCount()
{
lvaSetVarDoNotEnregister(lclNum DEBUGARG(DNER_IsStruct));
}
else if (!varDsc->IsEnregisterableType())
{
lvaSetVarDoNotEnregister(lclNum DEBUGARG(DNER_IsStruct));
}
}
if (varDsc->lvIsStructField && (lvaGetParentPromotionType(lclNum) != PROMOTION_TYPE_INDEPENDENT))
{
Expand Down
17 changes: 14 additions & 3 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6180,10 +6180,21 @@ void LinearScan::insertCopyOrReload(BasicBlock* block, GenTree* tree, unsigned m
}
else
{
// Create the new node, with "tree" as its only child.
var_types treeType = tree->TypeGet();
var_types regType = tree->TypeGet();
if ((regType == TYP_STRUCT) && !tree->IsMultiRegNode())
{
assert(compiler->compEnregStructLocals());
assert(tree->IsLocal());
const GenTreeLclVarCommon* lcl = tree->AsLclVarCommon();
const LclVarDsc* varDsc = compiler->lvaGetDesc(lcl);
// We create struct copies with a primitive type so we don't bother copy node with parsing structHndl.
// Note that for multiReg node we keep each regType in the tree and don't need this.
regType = varDsc->GetRegisterType(lcl);
assert(regType != TYP_UNDEF);
}

GenTreeCopyOrReload* newNode = new (compiler, oper) GenTreeCopyOrReload(oper, treeType, tree);
// Create the new node, with "tree" as its only child.
GenTreeCopyOrReload* newNode = new (compiler, oper) GenTreeCopyOrReload(oper, regType, tree);
assert(refPosition->registerAssignment != RBM_NONE);
SetLsraAdded(newNode);
newNode->SetRegNumByIdx(refPosition->assignedReg(), multiRegIdx);
Expand Down