From 1a40427d7c6c3c2a909150efd570f1cbe4d085dc Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 20 Jun 2024 16:26:41 -0700 Subject: [PATCH] Use fgUpdateConstTreeValueNumber where appropriate (#103771) --- src/coreclr/jit/gentree.cpp | 31 ++++++------------------------- src/coreclr/jit/optimizer.cpp | 11 +++-------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 502cd312bd073..fd9d2282c35cb 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -15923,10 +15923,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) // Fold into GT_IND of null byref. tree->BashToConst(0, TYP_BYREF); - if (vnStore != nullptr) - { - fgValueNumberTreeConst(tree); - } + fgUpdateConstTreeValueNumber(tree); JITDUMP("\nFolded to null byref:\n"); DISPTREE(tree); @@ -16128,10 +16125,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) tree->BashToConst(static_cast(i1)); tree->AsIntCon()->gtFieldSeq = fieldSeq; - if (vnStore != nullptr) - { - fgValueNumberTreeConst(tree); - } + fgUpdateConstTreeValueNumber(tree); JITDUMP("Bashed to int constant:\n"); DISPTREE(tree); @@ -16351,10 +16345,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) #ifdef TARGET_64BIT tree->AsIntCon()->gtFieldSeq = fieldSeq; #endif - if (vnStore != nullptr) - { - fgValueNumberTreeConst(tree); - } + fgUpdateConstTreeValueNumber(tree); JITDUMP("Bashed to long constant:\n"); DISPTREE(tree); @@ -16509,10 +16500,7 @@ GenTree* Compiler::gtFoldExprConst(GenTree* tree) (tree->gtDebugFlags & GTF_DEBUG_NODE_LARGE)); tree->BashToConst(d1, tree->TypeGet()); - if (vnStore != nullptr) - { - fgValueNumberTreeConst(tree); - } + fgUpdateConstTreeValueNumber(tree); JITDUMP("Bashed to fp constant:\n"); DISPTREE(tree); @@ -29699,13 +29687,9 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree) if (fgGlobalMorph) { INDEBUG(vecCon->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); - ; } - if (vnStore != nullptr) - { - fgValueNumberTreeConst(vecCon); - } + fgUpdateConstTreeValueNumber(vecCon); return vecCon; } @@ -30630,10 +30614,7 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree) if (resultNode->OperIsConst()) { - if (vnStore != nullptr) - { - fgValueNumberTreeConst(resultNode); - } + fgUpdateConstTreeValueNumber(resultNode); // Make sure no side effect flags are set on this constant node. resultNode->gtFlags &= ~GTF_ALL_EFFECT; diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index ee576b1bc3596..07e6ad745e370 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -3320,10 +3320,7 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu if (doit) { tree->BashToConst(static_cast(lval)); - if (vnStore != nullptr) - { - fgValueNumberTreeConst(tree); - } + fgUpdateConstTreeValueNumber(tree); } return true; @@ -3372,10 +3369,8 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu { tree->gtType = TYP_INT; tree->AsIntCon()->gtIconVal = (int)ival; - if (vnStore != nullptr) - { - fgValueNumberTreeConst(tree); - } + + fgUpdateConstTreeValueNumber(tree); } #endif // TARGET_64BIT