Skip to content

Commit

Permalink
Copy propagate on LCL_FLDs (#68592)
Browse files Browse the repository at this point in the history
  • Loading branch information
SingleAccretion authored May 11, 2022
1 parent 52fd1a5 commit 9158543
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/coreclr/jit/copyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,18 @@ void Compiler::optCopyProp(Statement* stmt, GenTreeLclVarCommon* tree, unsigned
continue;
}

var_types newLclType = newLclVarDsc->TypeGet();
if (!newLclVarDsc->lvNormalizeOnLoad())
if (tree->OperIs(GT_LCL_VAR))
{
newLclType = genActualType(newLclType);
}
var_types newLclType = newLclVarDsc->TypeGet();
if (!newLclVarDsc->lvNormalizeOnLoad())
{
newLclType = genActualType(newLclType);
}

if (newLclType != tree->TypeGet())
{
continue;
if (newLclType != tree->TypeGet())
{
continue;
}
}

#ifdef DEBUG
Expand Down Expand Up @@ -388,8 +391,7 @@ void Compiler::optBlockCopyProp(BasicBlock* block, LclNumToLiveDefsMap* curSsaNa

optCopyPropPushDef(tree, lclDefNode, lclNum, curSsaName);
}
// TODO-CQ: propagate on LCL_FLDs too.
else if (tree->OperIs(GT_LCL_VAR) && ((tree->gtFlags & GTF_VAR_DEF) == 0))
else if (tree->OperIs(GT_LCL_VAR, GT_LCL_FLD) && ((tree->gtFlags & GTF_VAR_DEF) == 0))
{
const unsigned lclNum = optIsSsaLocal(tree->AsLclVarCommon());

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8136,7 +8136,7 @@ GenTree* Compiler::gtCloneExpr(
new (this, GT_LCL_FLD) GenTreeLclFld(GT_LCL_FLD, tree->TypeGet(), tree->AsLclFld()->GetLclNum(),
tree->AsLclFld()->GetLclOffs());
copy->AsLclFld()->SetFieldSeq(tree->AsLclFld()->GetFieldSeq());
copy->gtFlags = tree->gtFlags;
copy->AsLclFld()->SetSsaNum(tree->AsLclFld()->GetSsaNum());
}
goto DONE;

Expand Down

0 comments on commit 9158543

Please sign in to comment.