From a6a072edac95af9621e149aa55a5f4aa84892600 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 15 Jun 2021 14:23:13 -0700 Subject: [PATCH] Keep obj node for ArrayIndex. --- src/coreclr/jit/morph.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 2d0d108a3349c..6d7f8c7bc6fdc 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -5509,8 +5509,16 @@ GenTree* Compiler::fgMorphArrayIndex(GenTree* tree) fgSetRngChkTarget(indexAddr); } - // Change `tree` into an indirection and return. - tree->ChangeOper(GT_IND); + if (!tree->TypeIs(TYP_STRUCT)) + { + tree->ChangeOper(GT_IND); + } + else + { + DEBUG_DESTROY_NODE(tree); + tree = gtNewObjNode(elemStructType, indexAddr); + INDEBUG(tree->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); + } GenTreeIndir* const indir = tree->AsIndir(); indir->Addr() = indexAddr; bool canCSE = indir->CanCSE(); @@ -5520,9 +5528,7 @@ GenTree* Compiler::fgMorphArrayIndex(GenTree* tree) indir->SetDoNotCSE(); } -#ifdef DEBUG - indexAddr->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED; -#endif // DEBUG + INDEBUG(indexAddr->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); return indir; }