Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: run local struct to field update in morph both pre and post order for returns #75304

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Changes from 1 commit
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: 12 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10243,6 +10243,18 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
{
op1 = fgMorphRetInd(tree->AsUnOp());
}
// Local assertions may enable zero or copy prop.
//
if (fgGlobalMorph && optLocalAssertionProp && (optAssertionCount > 0) && op1->OperIs(GT_LCL_VAR))
{
GenTree* newOp1 = op1;
while (newOp1 != nullptr)
{
op1 = newOp1;
newOp1 = optAssertionProp(apFull, newOp1, nullptr, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would feel like a lesser evil to "retry" replacing the local with its promoted field in post-order to me. It would be more in line with how the other decomposition transforms work.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree it seems like a more natural fit.

I had a version that did that, but it caused LSRA churn (though not too much).

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a version that did that, but it caused LSRA churn (though not too much).

It seems a bit surprising it did -- wouldn't the lack of this replacement cause the failure (assert) being fixed?

To be clear, I meant trying the replacement on both pre- and post- order.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was trying it both places. I'll revive that version....

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like my earlier assessment was wrong; doing the update both pre and post order works nicely and has no diffs on win x64 or x86.

Updated.

}
assert(op1 != nullptr);
}
if (op1->OperIs(GT_LCL_VAR))
{
// With a `genReturnBB` this `RETURN(src)` tree will be replaced by a `ASG(genReturnLocal, src)`
Expand Down