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

Conversation

AndyAyersMS
Copy link
Member

@AndyAyersMS AndyAyersMS commented Sep 8, 2022

In some rare cases (currently only jitstress) morph may miss out in updating a return of a "struct that can be replaced by its field" with the field. But because we run local assertion prop after we check for this update, assertion prop it may change the local from one that could not be updated into one that could be, and if this happens, we miss out on a (required) update.

So, retry the update in post order, after the return operand has been morphed.

Fixes #74900.

…to field

In some rare cases (currently only jitstress) morph may miss out in updating a
return of a "struct that can be replaced by its field" with the field, because
we run local assertion prop afterward we check for this update, and assertion
prop, and it may change the local from one that could not be updated into one
that could be.

So do a special run of assertion prop before this update, so that the local we
analyze for possible update is same the one we'll be using in the end.

I tried moving all of this to post-order so local assertion prop only ran
once but that lead to more diffs and some regressions.

Fixes dotnet#74900.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 8, 2022
@ghost ghost assigned AndyAyersMS Sep 8, 2022
@ghost
Copy link

ghost commented Sep 8, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

…to field

In some rare cases (currently only jitstress) morph may miss out in updating a return of a "struct that can be replaced by its field" with the field, because we run local assertion prop afterward we check for this update, and assertion prop, and it may change the local from one that could not be updated into one that could be.

So do a special run of assertion prop before this update, so that the local we analyze for possible update is same the one we'll be using in the end.

I tried moving all of this to post-order so local assertion prop only ran once but that lead to more diffs and some regressions.

Fixes #74900.

Author: AndyAyersMS
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Sep 8, 2022

@jakobbotsch PTAL
cc @dotnet/jit-contrib

No diffs (prior commit had minor diffs).

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.

@AndyAyersMS
Copy link
Member Author

Native AOT tests timed out, seems like this is #75005 with a fix forthcoming.

@AndyAyersMS AndyAyersMS changed the title JIT: run local assertion prop before morphing return of local struct … JIT: run local struct to field update in morph both pre and post order for returns Sep 9, 2022
@AndyAyersMS
Copy link
Member Author

@jakobbotsch ping

@AndyAyersMS AndyAyersMS merged commit b583258 into dotnet:main Sep 13, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure JIT\\Performance\\CodeQuality\\Roslyn\\CscBench\\CscBench.cmd
3 participants