summaryrefslogtreecommitdiff
path: root/src/jit/earlyprop.cpp
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2016-12-27 16:46:08 +0900
commitdb20f3f1bb8595633a7e16c8900fd401a453a6b5 (patch)
treee5435159cd1bf0519276363a6fe1663d1721bed3 /src/jit/earlyprop.cpp
parent4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (diff)
downloadcoreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.gz
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.tar.bz2
coreclr-db20f3f1bb8595633a7e16c8900fd401a453a6b5.zip
Imported Upstream version 1.0.0.9127upstream/1.0.0.9127
Diffstat (limited to 'src/jit/earlyprop.cpp')
-rw-r--r--src/jit/earlyprop.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/jit/earlyprop.cpp b/src/jit/earlyprop.cpp
index 70d1012aa0..51de631d19 100644
--- a/src/jit/earlyprop.cpp
+++ b/src/jit/earlyprop.cpp
@@ -189,8 +189,7 @@ void Compiler::optEarlyProp()
// Walk the stmt tree in linear order to rewrite any array length reference with a
// constant array length.
- bool isRewritten = false;
- bool bbHasNullCheck = (block->bbFlags & BBF_HAS_NULLCHECK) != 0;
+ bool isRewritten = false;
for (GenTreePtr tree = stmt->gtStmt.gtStmtList; tree != nullptr; tree = tree->gtNext)
{
if (optEarlyPropRewriteTree(tree))
@@ -238,12 +237,8 @@ bool Compiler::optEarlyPropRewriteTree(GenTreePtr tree)
objectRefPtr = tree->gtOp.gtOp1;
propKind = optPropKind::OPK_ARRAYLEN;
}
- else if ((tree->OperGet() == GT_IND) && !varTypeIsStruct(tree))
+ else if (tree->OperIsIndir())
{
- // TODO-1stClassStructs: The above condition should apply equally to all indirections,
- // but previously the implicit indirections due to a struct assignment were not
- // considered, so we are currently limiting it to non-structs to preserve existing
- // behavior.
// optFoldNullCheck takes care of updating statement info if a null check is removed.
optFoldNullCheck(tree);
@@ -259,7 +254,7 @@ bool Compiler::optEarlyPropRewriteTree(GenTreePtr tree)
return false;
}
- objectRefPtr = tree->gtOp.gtOp1;
+ objectRefPtr = tree->AsIndir()->Addr();
propKind = optPropKind::OPK_OBJ_GETTYPE;
}
else
@@ -511,15 +506,23 @@ void Compiler::optFoldNullCheck(GenTreePtr tree)
// |
// x
- assert(tree->OperGet() == GT_IND);
- if (tree->gtGetOp1()->OperGet() == GT_LCL_VAR)
+ if ((compCurBB->bbFlags & BBF_HAS_NULLCHECK) == 0)
+ {
+ return;
+ }
+
+ assert(tree->OperIsIndir());
+
+ GenTree* const addr = tree->AsIndir()->Addr();
+ if (addr->OperGet() == GT_LCL_VAR)
{
// Check if we have the pattern above and find the nullcheck node if we do.
// Find the definition of the indirected local (x in the picture)
- GenTreePtr indLocalTree = tree->gtGetOp1();
- unsigned lclNum = indLocalTree->AsLclVarCommon()->GetLclNum();
- unsigned ssaNum = indLocalTree->AsLclVarCommon()->GetSsaNum();
+ GenTreeLclVarCommon* const lclVarNode = addr->AsLclVarCommon();
+
+ const unsigned lclNum = lclVarNode->GetLclNum();
+ const unsigned ssaNum = lclVarNode->GetSsaNum();
if (ssaNum != SsaConfig::RESERVED_SSA_NUM)
{
@@ -557,7 +560,7 @@ void Compiler::optFoldNullCheck(GenTreePtr tree)
{
// Walk from the use to the def in reverse execution order to see
// if any nodes have unsafe side effects.
- GenTreePtr currentTree = indLocalTree->gtPrev;
+ GenTreePtr currentTree = lclVarNode->gtPrev;
bool isInsideTry = compCurBB->hasTryIndex();
bool canRemoveNullCheck = true;
const unsigned maxNodesWalked = 25;
@@ -612,13 +615,8 @@ void Compiler::optFoldNullCheck(GenTreePtr tree)
additionNode->gtFlags & (GTF_EXCEPT | GTF_DONT_CSE);
// Re-morph the statement.
- fgMorphBlockStmt(compCurBB, curStmt DEBUGARG("optFoldNullCheck"));
-
- // Recalculate the gtCostSz, etc...
- gtSetStmtInfo(curStmt);
-
- // Re-thread the nodes
- fgSetStmtSeq(curStmt);
+ fgMorphBlockStmt(compCurBB,
+ curStmt->AsStmt() DEBUGARG("optFoldNullCheck"));
}
}
}
@@ -668,4 +666,4 @@ bool Compiler::optCanMoveNullCheckPastTree(GenTreePtr tree, bool isInsideTry)
}
}
return result;
-} \ No newline at end of file
+}