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

JIT: Support some assignment decomposition in physical promotion #85105

Merged
Merged
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,7 @@ class Compiler
static bool gtHasRef(GenTree* tree, unsigned lclNum);

bool gtHasLocalsWithAddrOp(GenTree* tree);
bool gtHasAddressExposedLocals(GenTree* tree);

unsigned gtSetCallArgsOrder(CallArgs* args, bool lateArgs, int* callCostEx, int* callCostSz);
unsigned gtSetMultiOpOrder(GenTreeMultiOp* multiOp);
Expand Down
59 changes: 53 additions & 6 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2982,8 +2982,6 @@ bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree)
DoLclVarsOnly = true,
};

bool HasAddrTakenLocal = false;

LocalsWithAddrOpVisitor(Compiler* comp) : GenTreeVisitor(comp)
{
}
Expand All @@ -2993,7 +2991,6 @@ bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree)
LclVarDsc* varDsc = m_compiler->lvaGetDesc((*use)->AsLclVarCommon());
if (varDsc->lvHasLdAddrOp || varDsc->IsAddressExposed())
{
HasAddrTakenLocal = true;
return WALK_ABORT;
}

Expand All @@ -3002,8 +2999,48 @@ bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree)
};

LocalsWithAddrOpVisitor visitor(this);
visitor.WalkTree(&tree, nullptr);
return visitor.HasAddrTakenLocal;
return visitor.WalkTree(&tree, nullptr) == WALK_ABORT;
}

//------------------------------------------------------------------------------
// gtHasAddressExposedLocal:
// Check if this tree contains locals with IsAddressExposed() flags set. Does
// a full tree walk.
//
// Paramters:
// tree - the tree
//
// Return Value:
// True if any sub tree is such a local.
//
bool Compiler::gtHasAddressExposedLocals(GenTree* tree)
{
struct Visitor : GenTreeVisitor<Visitor>
{
enum
{
DoPreOrder = true,
DoLclVarsOnly = true,
};

Visitor(Compiler* comp) : GenTreeVisitor(comp)
{
}

fgWalkResult PreOrderVisit(GenTree** use, GenTree* user)
{
LclVarDsc* varDsc = m_compiler->lvaGetDesc((*use)->AsLclVarCommon());
if (varDsc->IsAddressExposed())
{
return WALK_ABORT;
}

return WALK_CONTINUE;
}
};

Visitor visitor(this);
return visitor.WalkTree(&tree, nullptr) == WALK_ABORT;
}

#ifdef DEBUG
Expand Down Expand Up @@ -16353,7 +16390,17 @@ bool Compiler::gtSplitTree(

bool IsValue(const UseInfo& useInf)
{
GenTree* node = (*useInf.Use)->gtEffectiveVal();
GenTree* node = *useInf.Use;

// Some places create void-typed commas that wrap actual values
// (e.g. VN-based dead store removal), so we need the double check
// here.
if (!node->IsValue())
{
return false;
}

node = node->gtEffectiveVal();
if (!node->IsValue())
{
return false;
Expand Down
Loading