Skip to content

Commit

Permalink
Mitigate some TP
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch committed Mar 24, 2023
1 parent 298c2d1 commit 768c3ff
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9827,8 +9827,8 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA

// Only do this optimization when we are in the global optimizer. Doing this after value numbering
// could result in an invalid value number for the newly generated GT_IND node.
bool mightBeLocation = (tree->gtFlags & GTF_DONT_CSE) != 0;
if ((op1->OperGet() == GT_COMMA) && fgGlobalMorph && !mightBeLocation)
// We skip INDs with GTF_DONT_CSE which is set if the IND is a location.
if (op1->OperIs(GT_COMMA) && fgGlobalMorph && ((tree->gtFlags & GTF_DONT_CSE) == 0))
{
// Perform the transform IND(COMMA(x, ..., z)) -> COMMA(x, ..., IND(z)).
GenTree* commaNode = op1;
Expand Down Expand Up @@ -10046,25 +10046,21 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
// nodes may have CSE defs/uses in them.
if (fgGlobalMorph && (oper != GT_ASG) && (oper != GT_COLON))
{
bool mightBeLocation = (tree->OperIsIndir() || tree->OperIsLocal()) && ((tree->gtFlags & GTF_DONT_CSE) != 0);
if (!mightBeLocation)
if ((op1 != nullptr) && fgIsCommaThrow(op1, true))
{
if ((op1 != nullptr) && fgIsCommaThrow(op1, true))
GenTree* propagatedThrow = fgPropagateCommaThrow(tree, op1->AsOp(), GTF_EMPTY);
if (propagatedThrow != nullptr)
{
GenTree* propagatedThrow = fgPropagateCommaThrow(tree, op1->AsOp(), GTF_EMPTY);
if (propagatedThrow != nullptr)
{
return propagatedThrow;
}
return propagatedThrow;
}
}

if ((op2 != nullptr) && fgIsCommaThrow(op2, true))
if ((op2 != nullptr) && fgIsCommaThrow(op2, true))
{
GenTree* propagatedThrow = fgPropagateCommaThrow(tree, op2->AsOp(), op1->gtFlags & GTF_ALL_EFFECT);
if (propagatedThrow != nullptr)
{
GenTree* propagatedThrow = fgPropagateCommaThrow(tree, op2->AsOp(), op1->gtFlags & GTF_ALL_EFFECT);
if (propagatedThrow != nullptr)
{
return propagatedThrow;
}
return propagatedThrow;
}
}
}
Expand Down Expand Up @@ -11506,6 +11502,13 @@ GenTree* Compiler::fgPropagateCommaThrow(GenTree* parent, GenTreeOp* commaThrow,
assert(fgGlobalMorph);
assert(fgIsCommaThrow(commaThrow));

bool mightBeLocation = (parent->OperIsLocal() || parent->OperIsIndir()) && ((parent->gtFlags & GTF_DONT_CSE) != 0);

if (mightBeLocation)
{
return nullptr;
}

if ((commaThrow->gtFlags & GTF_COLON_COND) == 0)
{
fgRemoveRestOfBlock = true;
Expand Down

0 comments on commit 768c3ff

Please sign in to comment.