Skip to content

Commit

Permalink
Enreg structs x86 windows. (#55535)
Browse files Browse the repository at this point in the history
* Mark more cases as DoNotEnreg before CSE.

There are CSE metrics that take into account how many potential enreg locals
do we have.

* enable for x86.
  • Loading branch information
Sergey Andreenko authored Jul 13, 2021
1 parent 7b19cce commit 92ed400
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
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

0 comments on commit 92ed400

Please sign in to comment.