Skip to content

Commit

Permalink
update vn during copy prop, fix dump issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyAyersMS committed Jul 16, 2024
1 parent ccdca2a commit 6a21ba3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/coreclr/jit/copyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool Compiler::optCopyProp(
continue;
}

JITDUMP("orig [%06] copy [%06u] VNs proved equivalent\n", dspTreeID(tree),
JITDUMP("orig [%06u] copy [%06u] VNs proved equivalent\n", dspTreeID(tree),
dspTreeID(newLclDef.GetDefNode()));
}

Expand Down Expand Up @@ -281,6 +281,24 @@ bool Compiler::optCopyProp(

tree->AsLclVarCommon()->SetLclNum(newLclNum);
tree->AsLclVarCommon()->SetSsaNum(newSsaNum);

// Update VN to match, and propagate up through any enclosing commas.
// (we could in principle try updating through other parents, but
// we lack VN's context for memory, so can't get them all).
//
if (newLclDefVN != lclDefVN)
{
tree->SetVNs(newLclSsaDef->m_vnPair);
GenTree* parent = tree->gtGetParent(nullptr);

while ((parent != nullptr) && parent->OperIs(GT_COMMA))
{
JITDUMP(" Updating COMMA parent VN [%06u]\n", dspTreeID(parent));
ValueNumPair op1Xvnp = vnStore->VNPExceptionSet(parent->AsOp()->gtOp1->gtVNPair);
parent->SetVNs(vnStore->VNPWithExc(parent->AsOp()->gtOp2->gtVNPair, op1Xvnp));
parent = tree->gtGetParent(nullptr);
}
}
gtUpdateSideEffects(stmt, tree);
newLclSsaDef->AddUse(block);

Expand Down

0 comments on commit 6a21ba3

Please sign in to comment.