Skip to content

Commit 741f5c7

Browse files
Do not drop ADDR(INDEX) in impBoxPatternMatch
1 parent 0eb832f commit 741f5c7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/coreclr/jit/importer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6983,9 +6983,14 @@ int Compiler::impBoxPatternMatch(CORINFO_RESOLVED_TOKEN* pResolvedToken,
69836983
if (((treeToBox->gtFlags & GTF_SIDE_EFFECT) == GTF_EXCEPT) &&
69846984
treeToBox->OperIs(GT_OBJ, GT_BLK, GT_IND))
69856985
{
6986-
// Yes, we just need to perform a null check if needed.
6986+
// If the only side effect comes from the dereference itself, yes.
69876987
GenTree* const addr = treeToBox->AsOp()->gtGetOp1();
6988-
if (fgAddrCouldBeNull(addr))
6988+
6989+
if ((addr->gtFlags & GTF_SIDE_EFFECT) != 0)
6990+
{
6991+
canOptimize = false;
6992+
}
6993+
else if (fgAddrCouldBeNull(addr))
69896994
{
69906995
treeToNullcheck = addr;
69916996
}

0 commit comments

Comments
 (0)