diff options
Diffstat (limited to 'src/jit/assertionprop.cpp')
-rw-r--r-- | src/jit/assertionprop.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/jit/assertionprop.cpp b/src/jit/assertionprop.cpp index cd1b90ffa2..5b62e88303 100644 --- a/src/jit/assertionprop.cpp +++ b/src/jit/assertionprop.cpp @@ -3901,11 +3901,22 @@ GenTree* Compiler::optAssertionProp_Update(GenTree* newTree, GenTree* tree, GenT // locate our parent node and update it so that it points to newTree. if (newTree != tree) { - GenTree** link = gtFindLink(stmt, tree); - noway_assert(link != nullptr); + FindLinkData linkData = gtFindLink(stmt, tree); + GenTree** useEdge = linkData.result; + GenTree* parent = linkData.parent; + noway_assert(useEdge != nullptr); - // Replace the old operand with the newTree - *link = newTree; + if (parent != nullptr) + { + parent->ReplaceOperand(useEdge, newTree); + } + else + { + // If there's no parent, the tree being replaced is the root of the + // statement. + assert((stmt->gtStmtExpr == tree) && (&stmt->gtStmtExpr == useEdge)); + stmt->gtStmtExpr = newTree; + } // We only need to ensure that the gtNext field is set as it is used to traverse // to the next node in the tree. We will re-morph this entire statement in |