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

Only widen short local stores #74685

Merged
merged 5 commits into from
Sep 14, 2022

Conversation

SingleAccretion
Copy link
Contributor

@SingleAccretion SingleAccretion commented Aug 26, 2022

As the commit message points out, widening byte stores is not profitable most of the time.

This change is meant to minimize the amount of regressions for the upcoming enablement of folding primitives in local morph.

Diffs.

@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 Aug 26, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Aug 26, 2022
@ghost
Copy link

ghost commented Aug 26, 2022

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

Issue Details

As the commit message points out, widening byte stores is not profitable most of the time.

This change is meant to minimize the amount of regressions for the upcoming enablement of folding primitives in local morph.

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

// Widening byte -> int:
//
// Zero     : 3 -> 4/2
// Non-Zero : 3 -> 6
//
// Notable: only the "reused zero" case can become better.
//
// Widening short -> int:
//
// Zero     : 5 -> 4/2
// Non-Zero : 5 -> 6 (no 0x66 prefix)
//
// Notable: the zero (common) case is always better, while
// for the non-zero case we only regress by one byte and
// get rid of the prefix.
@SingleAccretion SingleAccretion changed the title Only widen 2 byte wide local stores Only widen short local stores Aug 26, 2022
@SingleAccretion SingleAccretion marked this pull request as ready for review August 27, 2022 22:07
@SingleAccretion
Copy link
Contributor Author

@dotnet/jit-contrib

@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.0 milestone Aug 29, 2022
@AndyAyersMS
Copy link
Member

@jakobbotsch can you review?

@jakobbotsch
Copy link
Member

/azp run runtime-coreclr superpmi-diffs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines 48 to 49
// Most small locals (the exception is dependently promoted fields) have 4 byte wide stack slots, so
// we can widen the store, if profitable. This optimization is not relevant for register candidates.
Copy link
Member

Choose a reason for hiding this comment

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

ARM has the same "optimization" (which does not make much sense on ARM I think). Should it be adjusted? It does not have the lvDoNotEnregister heuristic check, but it probably makes sense to remove it entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ARM

I've investigated this question a while back.

  1. For ARM64 this widening is useless. I'll #ifdef it out and delete the LA64 copy.
  2. For ARM, it can be useful because 4-byte-wide stores can be encoded in 2 bytes in more cases than the small ones. I'll make the code look more like this new x86/x64 version.

It does not have the lvDoNotEnregister heuristic check, but it probably makes sense to remove it entirely.

Yes... Not sure why I put that in; it's true that the "optimization" is only relevant for in-memory locals, but even candidates can end up spilled. I'll remove it.

On LA64, all instructions have the same size
of 4 bytes, so there is no point to widening.
No point in widening on ARM64.
@jakobbotsch jakobbotsch merged commit 522f808 into dotnet:main Sep 14, 2022
@SingleAccretion SingleAccretion deleted the Small-Store-Widening branch September 17, 2022 16:35
@ghost ghost locked as resolved and limited conversation to collaborators Oct 17, 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 community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants