Skip to content

Commit

Permalink
Keep obj node for ArrayIndex. (#54584)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Andreenko authored Jun 23, 2021
1 parent 1f5033c commit 9701ef9
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down

0 comments on commit 9701ef9

Please sign in to comment.