Skip to content

Commit 49d8509

Browse files
committed
Reuse existing comma node
1 parent 6eca58d commit 49d8509

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/coreclr/jit/gentree.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -17139,7 +17139,15 @@ GenTree* Compiler::gtWrapWithSideEffects(GenTree* tree,
1713917139
// It should be possible to be smarter here and allow such cases by extracting the side effects
1714017140
// properly for this particular case. For now, caller is responsible for avoiding such cases.
1714117141

17142-
tree = gtNewOperNode(GT_COMMA, tree->TypeGet(), sideEffects, tree);
17142+
if (sideEffectsSource->OperIs(GT_COMMA) && sideEffectsSource->AsOp()->gtOp1 == sideEffects)
17143+
{
17144+
sideEffectsSource->AsOp()->gtOp2 = tree;
17145+
return sideEffectsSource;
17146+
}
17147+
else
17148+
{
17149+
tree = gtNewOperNode(GT_COMMA, tree->TypeGet(), sideEffects, tree);
17150+
}
1714317151
}
1714417152
return tree;
1714517153
}

0 commit comments

Comments
 (0)