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

Let GenTreeCopyOrReload handle scenarios when FEATURE_MULTIREG_RET is disabled #82451

Merged
merged 3 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 4 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,12 +975,12 @@ bool GenTree::IsMultiRegNode() const
return AsMultiRegOp()->GetRegCount() > 1;
}
#endif
#endif // FEATURE_MULTIREG_RET

if (OperIs(GT_COPY, GT_RELOAD))
{
return true;
}
#endif // FEATURE_MULTIREG_RET

#ifdef FEATURE_HW_INTRINSICS
if (OperIsHWIntrinsic())
Expand Down Expand Up @@ -1026,12 +1026,12 @@ unsigned GenTree::GetMultiRegCount(Compiler* comp) const
return AsMultiRegOp()->GetRegCount();
}
#endif
#endif // FEATURE_MULTIREG_RET

if (OperIs(GT_COPY, GT_RELOAD))
{
return AsCopyOrReload()->GetRegCount();
}
#endif // FEATURE_MULTIREG_RET

#ifdef FEATURE_HW_INTRINSICS
if (OperIsHWIntrinsic())
Expand Down Expand Up @@ -11696,7 +11696,8 @@ void Compiler::gtDispLeaf(GenTree* tree, IndentStack* indentStack)
fieldVarDsc->PrintVarReg();
}

if (fieldVarDsc->lvTracked && fgLocalVarLivenessDone && tree->AsLclVar()->IsLastUse(index))
if (fieldVarDsc->lvTracked && fgLocalVarLivenessDone &&
tree->AsLclVarCommon()->IsLastUse(index))
{
printf(" (last use)");
}
Expand Down
23 changes: 3 additions & 20 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -8039,17 +8039,14 @@ struct GenTreePutArgSplit : public GenTreePutArgStk
// Represents GT_COPY or GT_RELOAD node
//
// As it turns out, these are only needed on targets that happen to have multi-reg returns.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// As it turns out, these are only needed on targets that happen to have multi-reg returns.
// Needed to support multi-reg ops.

// However, they are actually needed on any target that has any multi-reg ops. It is just
// coincidence that those are the same (and there isn't a FEATURE_MULTIREG_OPS).
// However, they are actually needed on any target that has any multi-reg ops.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// However, they are actually needed on any target that has any multi-reg ops.

Otherwise the comments contradict themselves:

... are only needed on targets that happen to have multi-reg returns ...
... are actually needed on any target that has any multi-reg ops ...

//
struct GenTreeCopyOrReload : public GenTreeUnOp
{
#if FEATURE_MULTIREG_RET
// State required to support copy/reload of a multi-reg call node.
// The first register is always given by GetRegNum().
//
regNumberSmall gtOtherRegs[MAX_MULTIREG_COUNT - 1];
#endif

//----------------------------------------------------------
// ClearOtherRegs: set gtOtherRegs to REG_NA.
Expand All @@ -8062,12 +8059,10 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
//
void ClearOtherRegs()
{
#if FEATURE_MULTIREG_RET
for (unsigned i = 0; i < MAX_MULTIREG_COUNT - 1; ++i)
{
gtOtherRegs[i] = REG_NA;
}
#endif
}

//-----------------------------------------------------------
Expand All @@ -8088,11 +8083,7 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
return GetRegNum();
}

#if FEATURE_MULTIREG_RET
return (regNumber)gtOtherRegs[idx - 1];
#else
return REG_NA;
#endif
}

//-----------------------------------------------------------
Expand All @@ -8113,18 +8104,11 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
{
SetRegNum(reg);
}
#if FEATURE_MULTIREG_RET
else
{
gtOtherRegs[idx - 1] = (regNumberSmall)reg;
assert(gtOtherRegs[idx - 1] == reg);
}
#else
else
{
unreached();
}
#endif
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -8153,7 +8137,6 @@ struct GenTreeCopyOrReload : public GenTreeUnOp

unsigned GetRegCount() const
{
#if FEATURE_MULTIREG_RET
// We need to return the highest index for which we have a valid register.
// Note that the gtOtherRegs array is off by one (the 0th register is GetRegNum()).
// If there's no valid register in gtOtherRegs, GetRegNum() must be valid.
Expand All @@ -8168,7 +8151,7 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
return i;
}
}
#endif

// We should never have a COPY or RELOAD with no valid registers.
assert(GetRegNum() != REG_NA);
return 1;
Expand Down Expand Up @@ -9097,12 +9080,12 @@ inline regNumber GenTree::GetRegByIndex(int regIndex) const
return AsMultiRegOp()->GetRegNumByIdx(regIndex);
}
#endif
#endif // FEATURE_MULTIREG_RET

if (OperIs(GT_COPY, GT_RELOAD))
{
return AsCopyOrReload()->GetRegNumByIdx(regIndex);
}
#endif // FEATURE_MULTIREG_RET

#ifdef FEATURE_HW_INTRINSICS
if (OperIs(GT_HWINTRINSIC))
Expand Down