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

Some small copy propagation changes #66582

Merged
Merged
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
21 changes: 19 additions & 2 deletions src/coreclr/jit/copyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void Compiler::optCopyPropPushDef(GenTreeOp* asg,
{
assert((lclNode->gtFlags & GTF_VAR_DEF) != 0);

// Quirk: do not collect defs from PHIs. Preserves previous behavior.
// TODO-CQ: design better heuristics for propagation and remove this condition.
if (!asg->IsPhiDefn())
{
ssaDefNum = GetSsaNumForLocalVarDef(lclNode);
Expand Down Expand Up @@ -480,10 +480,27 @@ void Compiler::optVnCopyProp()
// TODO-Cleanup: Move this function from Compiler to this class.
m_compiler->optBlockCopyPropPopStacks(block, &m_curSsaName);
}

void PropagateCopies()
{
WalkTree();

#ifdef DEBUG
// Verify the definitions remaining are only those we pushed for parameters.
for (LclNumToLiveDefsMap::KeyIterator iter = m_curSsaName.Begin(); !iter.Equal(m_curSsaName.End()); ++iter)
{
unsigned lclNum = iter.Get();
assert(m_compiler->lvaGetDesc(lclNum)->lvIsParam || (lclNum == m_compiler->info.compThisArg));

CopyPropSsaDefStack* defStack = iter.GetValue();
assert(defStack->Height() == 1);
}
#endif // DEBUG
}
};

CopyPropDomTreeVisitor visitor(this);
visitor.WalkTree();
visitor.PropagateCopies();

// Tracked variable count increases after CopyProp, so don't keep a shorter array around.
// Destroy (release) the varset.
Expand Down