Skip to content

Commit 92ed400

Browse files
author
Sergey Andreenko
authored
Enreg structs x86 windows. (#55535)
* 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.
1 parent 7b19cce commit 92ed400

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/coreclr/jit/gentree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6801,6 +6801,7 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
68016801

68026802
GenTreeCopyOrReload(genTreeOps oper, var_types type, GenTree* op1) : GenTreeUnOp(oper, type, op1)
68036803
{
6804+
assert(type != TYP_STRUCT || op1->IsMultiRegNode());
68046805
SetRegNum(REG_NA);
68056806
ClearOtherRegs();
68066807
}

src/coreclr/jit/jitconfigvalues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ CONFIG_INTEGER(JitSaveFpLrWithCalleeSavedRegisters, W("JitSaveFpLrWithCalleeSave
555555
#endif // defined(TARGET_ARM64)
556556
#endif // DEBUG
557557

558-
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS)
558+
#if defined(TARGET_WINDOWS) && defined(TARGET_XARCH)
559559
CONFIG_INTEGER(JitEnregStructLocals, W("JitEnregStructLocals"), 1) // Allow to enregister locals with struct type.
560560
#else
561561
CONFIG_INTEGER(JitEnregStructLocals, W("JitEnregStructLocals"), 0) // Don't allow to enregister locals with struct type

src/coreclr/jit/lclvars.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,10 @@ void Compiler::lvaSortByRefCount()
34973497
{
34983498
lvaSetVarDoNotEnregister(lclNum DEBUGARG(DNER_IsStruct));
34993499
}
3500+
else if (!varDsc->IsEnregisterableType())
3501+
{
3502+
lvaSetVarDoNotEnregister(lclNum DEBUGARG(DNER_IsStruct));
3503+
}
35003504
}
35013505
if (varDsc->lvIsStructField && (lvaGetParentPromotionType(lclNum) != PROMOTION_TYPE_INDEPENDENT))
35023506
{

src/coreclr/jit/lsra.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6180,10 +6180,21 @@ void LinearScan::insertCopyOrReload(BasicBlock* block, GenTree* tree, unsigned m
61806180
}
61816181
else
61826182
{
6183-
// Create the new node, with "tree" as its only child.
6184-
var_types treeType = tree->TypeGet();
6183+
var_types regType = tree->TypeGet();
6184+
if ((regType == TYP_STRUCT) && !tree->IsMultiRegNode())
6185+
{
6186+
assert(compiler->compEnregStructLocals());
6187+
assert(tree->IsLocal());
6188+
const GenTreeLclVarCommon* lcl = tree->AsLclVarCommon();
6189+
const LclVarDsc* varDsc = compiler->lvaGetDesc(lcl);
6190+
// We create struct copies with a primitive type so we don't bother copy node with parsing structHndl.
6191+
// Note that for multiReg node we keep each regType in the tree and don't need this.
6192+
regType = varDsc->GetRegisterType(lcl);
6193+
assert(regType != TYP_UNDEF);
6194+
}
61856195

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

0 commit comments

Comments
 (0)