From b8d36c2d537e2307da58afda9bd765cfa7558bd3 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 21 Nov 2022 12:42:36 +0100 Subject: [PATCH] Make optVNAssertionPropCurStmtVisitor post-order --- src/coreclr/jit/assertionprop.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index 2c3fca0a28b233..f894aeacf1d55e 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -6054,7 +6054,7 @@ GenTree* Compiler::optVNConstantPropOnJTrue(BasicBlock* block, GenTree* test) // Performs constant prop on the current statement's tree nodes. // // Assumption: -// This function is called as part of a pre-order tree walk. +// This function is called as part of a post-order tree walk. // // Arguments: // tree - The currently visited tree node. @@ -6128,7 +6128,7 @@ Compiler::fgWalkResult Compiler::optVNConstantPropCurStmt(BasicBlock* block, Sta // Don't transform long multiplies. if (tree->gtFlags & GTF_MUL_64RSLT) { - return WALK_SKIP_SUBTREES; + return WALK_CONTINUE; } break; @@ -6166,16 +6166,15 @@ Compiler::fgWalkResult Compiler::optVNConstantPropCurStmt(BasicBlock* block, Sta return WALK_CONTINUE; } - // Successful propagation, mark as assertion propagated and skip - // sub-tree (with side-effects) visits. - // TODO #18291: at that moment stmt could be already removed from the stmt list. + // TODO https://github.com/dotnet/runtime/issues/10450: + // at that moment stmt could be already removed from the stmt list. optAssertionProp_Update(newTree, tree, stmt); JITDUMP("After constant propagation on [%06u]:\n", tree->gtTreeID); DBEXEC(VERBOSE, gtDispStmt(stmt)); - return WALK_SKIP_SUBTREES; + return WALK_CONTINUE; } //------------------------------------------------------------------------------ @@ -6222,7 +6221,7 @@ void Compiler::optVnNonNullPropCurStmt(BasicBlock* block, Statement* stmt, GenTr // Unified Value Numbering based assertion propagation visitor. // // Assumption: -// This function is called as part of a pre-order tree walk. +// This function is called as part of a post-order tree walk. // // Return Value: // WALK_RESULTs. @@ -6269,7 +6268,7 @@ Statement* Compiler::optVNAssertionPropCurStmt(BasicBlock* block, Statement* stm optAssertionPropagatedCurrentStmt = false; VNAssertionPropVisitorInfo data(this, block, stmt); - fgWalkTreePre(stmt->GetRootNodePointer(), Compiler::optVNAssertionPropCurStmtVisitor, &data); + fgWalkTreePost(stmt->GetRootNodePointer(), Compiler::optVNAssertionPropCurStmtVisitor, &data); if (optAssertionPropagatedCurrentStmt) {