diff options
Diffstat (limited to 'src/jit/copyprop.cpp')
-rw-r--r-- | src/jit/copyprop.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/jit/copyprop.cpp b/src/jit/copyprop.cpp index 773976e33e..75fc5c48ef 100644 --- a/src/jit/copyprop.cpp +++ b/src/jit/copyprop.cpp @@ -110,13 +110,17 @@ int Compiler::optCopyProp_LclVarScore(LclVarDsc* lclVarDsc, LclVarDsc* copyVarDs return score + ((preferOp2) ? 1 : -1); } -/************************************************************************************** - * - * Perform copy propagation on a given tree as we walk the graph and if it is a local - * variable, then look up all currently live definitions and check if any of those - * definitions share the same value number. If so, then we can make the replacement. - * - */ +//------------------------------------------------------------------------------ +// optCopyProp : Perform copy propagation on a given tree as we walk the graph and if it is a local +// variable, then look up all currently live definitions and check if any of those +// definitions share the same value number. If so, then we can make the replacement. +// +// Arguments: +// block - Block the tree belongs to +// stmt - Statement the tree belongs to +// tree - The tree to perform copy propagation on +// curSsaName - The map from lclNum to its recently live definitions as a stack + void Compiler::optCopyProp(BasicBlock* block, GenTreePtr stmt, GenTreePtr tree, LclNumToGenTreePtrStack* curSsaName) { // TODO-Review: EH successor/predecessor iteration seems broken. @@ -259,6 +263,7 @@ void Compiler::optCopyProp(BasicBlock* block, GenTreePtr stmt, GenTreePtr tree, lvaTable[newLclNum].incRefCnts(block->getBBWeight(this), this); tree->gtLclVarCommon.SetLclNum(newLclNum); tree->AsLclVarCommon()->SetSsaNum(newSsaNum); + gtUpdateSideEffects(stmt, tree); #ifdef DEBUG if (verbose) { @@ -280,13 +285,15 @@ bool Compiler::optIsSsaLocal(GenTreePtr tree) return tree->IsLocal() && !fgExcludeFromSsa(tree->AsLclVarCommon()->GetLclNum()); } -/************************************************************************************** - * - * Perform copy propagation using currently live definitions on the current block's - * variables. Also as new definitions are encountered update the "curSsaName" which - * tracks the currently live definitions. - * - */ +//------------------------------------------------------------------------------ +// optBlockCopyProp : Perform copy propagation using currently live definitions on the current block's +// variables. Also as new definitions are encountered update the "curSsaName" which +// tracks the currently live definitions. +// +// Arguments: +// block - Block the tree belongs to +// curSsaName - The map from lclNum to its recently live definitions as a stack + void Compiler::optBlockCopyProp(BasicBlock* block, LclNumToGenTreePtrStack* curSsaName) { JITDUMP("Copy Assertion for BB%02u\n", block->bbNum); @@ -302,6 +309,7 @@ void Compiler::optBlockCopyProp(BasicBlock* block, LclNumToGenTreePtrStack* curS for (GenTreePtr tree = stmt->gtStmt.gtStmtList; tree; tree = tree->gtNext) { compUpdateLife</*ForCodeGen*/ false>(tree); + optCopyProp(block, stmt, tree, curSsaName); // TODO-Review: Merge this loop with the following loop to correctly update the |