Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13402,9 +13402,15 @@ GenTree* Compiler::gtFoldExpr(GenTree* tree)
}
else if (op1->OperIsConst() || op2->OperIsConst())
{
/* at least one is a constant - see if we have a
* special operator that can use only one constant
* to fold - e.g. booleans */
// At least one is a constant - see if we have a
// special operator that can use only one constant
// to fold - e.g. booleans

if (tier0opts && opts.OptimizationDisabled())
{
// Too heavy for tier0
return tree;
}

return gtFoldExprSpecial(tree);
}
Expand Down
19 changes: 5 additions & 14 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8028,10 +8028,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA

GenTree* oldTree = tree;

if (opts.OptimizationEnabled())
{
tree = gtFoldExpr(tree);
}
tree = gtFoldExpr(tree);

// Were we able to fold it ?
// Note that gtFoldExpr may return a non-leaf even if successful
Expand Down Expand Up @@ -8330,11 +8327,8 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
qmarkOp2 = oldTree->AsOp()->gtOp2->AsOp()->gtOp2;
}

if (opts.OptimizationEnabled())
{
// Try to fold it, maybe we get lucky,
tree = gtFoldExpr(tree);
}
// Try to fold it, maybe we get lucky,
tree = gtFoldExpr(tree);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a similar check for hwintrinsic, right? Should that be included in this or as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, looks like those are fine as is


if (oldTree != tree)
{
Expand Down Expand Up @@ -12360,11 +12354,8 @@ GenTree* Compiler::fgMorphTree(GenTree* tree, MorphAddrContext* mac)
tree->gtFlags |= tree->AsConditional()->gtOp1->gtFlags & GTF_ALL_EFFECT;
tree->gtFlags |= tree->AsConditional()->gtOp2->gtFlags & GTF_ALL_EFFECT;

if (opts.OptimizationEnabled())
{
// Try to fold away any constants etc.
tree = gtFoldExpr(tree);
}
// Try to fold away any constants etc.
tree = gtFoldExpr(tree);

break;

Expand Down