Skip to content

Commit

Permalink
Extend redundant zero init optimization to recognize assignments to `…
Browse files Browse the repository at this point in the history
…GT_OBJ(lcl_addr)` and `GT_BLK(lcl_addr)`

Fixes #38070.
  • Loading branch information
erozenfeld committed Jun 24, 2020
1 parent 69fca92 commit 9d35b6d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/coreclr/src/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9279,12 +9279,28 @@ void Compiler::optRemoveRedundantZeroInits()
case GT_ASG:
{
GenTreeOp* treeOp = tree->AsOp();
if (!treeOp->gtOp1->OperIs(GT_LCL_VAR, GT_LCL_FLD))

unsigned lclNum = BAD_VAR_NUM;

if (treeOp->gtOp1->OperIs(GT_LCL_VAR, GT_LCL_FLD))
{
lclNum = treeOp->gtOp1->AsLclVarCommon()->GetLclNum();
}
else if (treeOp->gtOp1->OperIs(GT_OBJ, GT_BLK))
{
GenTreeLclVarCommon* lcl = treeOp->gtOp1->gtGetOp1()->IsLocalAddrExpr();

if (lcl != nullptr)
{
lclNum = lcl->GetLclNum();
}
}

if (lclNum == BAD_VAR_NUM)
{
break;
}

unsigned lclNum = treeOp->gtOp1->AsLclVarCommon()->GetLclNum();
LclVarDsc* const lclDsc = lvaGetDesc(lclNum);
unsigned* pRefCount = refCounts.LookupPointer(lclNum);

Expand Down

0 comments on commit 9d35b6d

Please sign in to comment.