Skip to content

JIT: Insert readbacks eagerly in physical promotion #87809

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

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Jun 20, 2023

Physical promotion currently inserts readbacks (reading the struct local back into the field local) as COMMAs right before a local that needs it. This is not right for QMARKs where it may mean we only end up reading back the local in one of the branches.

This change makes physical promotion insert readbacks as new statements before any statement that is going to need it. While we could do this for QMARKs only, it is done for any statement indiscriminately since it has two benefits:

  1. It allows forward-sub to kick in for the readbacks, which can lead to a contained LCL_FLDs
  2. It stops us from disabling local copy prop by avoiding the creation of embedded stores.

The existing logic is still necessary to keep in case the readback was marked within the same tree.

Fix #87508
Fix #87506
Fix #87755

Physical promotion currently inserts readbacks (reading the struct local
back into the field local) as COMMAs right before a local that needs it.
This is not right for QMARKs where it may mean we only end up reading
back the local in one of the branches.

This change makes physical promotion insert readbacks as new statements
before any statement that is going to need it. While we could do this
for QMARKs only, it is done for any statement indiscriminately since it
has two benefits:
1. It allows forward-sub to kick in for the readbacks, which can lead to
   a contained LCL_FLD
2. It stops us from disabling local copy prop by avoiding the creation
   of embedded stores.

The existing logic is still necessary to keep in case the readback was
marked within the same tree.

Fix dotnet#87508
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 20, 2023
@ghost ghost assigned jakobbotsch Jun 20, 2023
@ghost
Copy link

ghost commented Jun 20, 2023

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

Issue Details

Physical promotion currently inserts readbacks (reading the struct local back into the field local) as COMMAs right before a local that needs it. This is not right for QMARKs where it may mean we only end up reading back the local in one of the branches.

This change makes physical promotion insert readbacks as new statements before any statement that is going to need it. While we could do this for QMARKs only, it is done for any statement indiscriminately since it has two benefits:

  1. It allows forward-sub to kick in for the readbacks, which can lead to a contained LCL_FLDs
  2. It stops us from disabling local copy prop by avoiding the creation of embedded stores.

The existing logic is still necessary to keep in case the readback was marked within the same tree.

Fix #87508

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress, runtime-jit-experimental

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jakobbotsch jakobbotsch marked this pull request as ready for review June 20, 2023 16:18
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

Diffs with physical promotion, diffs without old promotion.

@jakobbotsch jakobbotsch requested a review from AndyAyersMS June 20, 2023 16:23
@jakobbotsch jakobbotsch merged commit 78d4e69 into dotnet:main Jun 20, 2023
@jakobbotsch jakobbotsch deleted the fix-readbacks-in-qmarks branch June 20, 2023 17:44
@ghost ghost locked as resolved and limited conversation to collaborators Jul 20, 2023
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
2 participants