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

Improve TryTransformStoreObjAsStoreInd optimization. #55727

Merged
merged 2 commits into from
Jul 15, 2021

Conversation

sandreenko
Copy link
Contributor

@sandreenko sandreenko commented Jul 15, 2021

With #55558 in the main we can now start using structs in regs potential, this is a change to convert more STORE_BLK(dst, LCL_VAR) as STORE_IND(dst, LCL_VAR).
The second representation is better because STORE_IND allows LCL_VAR to be enregistered.

There was also a bug that the optimization was enabled for MinOpts and disabled for MaxOpts, fixed as well. It was not providing much value without enregistration so that was staying hidden for quite a while (since 5.0).

Some SPMI highlights:

libraries.crossgen2.Linux.arm64.checked.mch
Total bytes of delta: -62044
5947 total methods with Code Size differences (5861 improved, 86 regressed)

libraries.crossgen2.windows.x64.checked.mch
Total bytes of delta: -12882
945 total methods with Code Size differences (872 improved, 73 regressed), 804 unchanged.

asp and benchmarks are showing improvements as well.

Full diffs
coreclr_tests.pmi.windows.x64.checked.mch
Total bytes of delta: -10515
791 total files with Code Size differences (693 improved, 98 regressed), 2666 unchanged.

libraries.crossgen2.windows.x64.checked.mch
Total bytes of delta: -12882
945 total files with Code Size differences (872 improved, 73 regressed), 804 unchanged.

libraries.pmi.windows.x64.checked.mch
Total bytes of delta: -6776
945 total files with Code Size differences (800 improved, 145 regressed), 645 unchanged.

libraries_tests.pmi.windows.x64.checked.mch
Total bytes of delta: -20864
2300 total files with Code Size differences (2117 improved, 183 regressed), 986 unchanged.

aspnet.run.windows.x64.checked.mch
Total bytes of delta: -748
125 total files with Code Size differences (92 improved, 33 regressed), 206 unchanged.

benchmarks.run.windows.x64.checked.mch
Total bytes of delta: -390
34 total files with Code Size differences (26 improved, 8 regressed), 65 unchanged.

coreclr_tests.pmi.Linux.arm64.checked.mch
Total bytes of delta: -20528
413 total files with Code Size differences (325 improved, 88 regressed), 5906 unchanged.

libraries.crossgen2.Linux.arm64.checked.mch
Total bytes of delta: -62044
5947 total files with Code Size differences (5861 improved, 86 regressed), 3080 unchanged.

libraries.pmi.Linux.arm64.checked.mch
Total bytes of delta: -20184
1083 total files with Code Size differences (1024 improved, 59 regressed), 7333 unchanged.

libraries_tests.pmi.Linux.arm64.checked.mch
Total bytes of delta: -18652
2409 total files with Code Size differences (2281 improved, 128 regressed), 3993 unchanged.

benchmarks.run.Linux.x64.checked.mch
Total bytes of delta: -58
26 total files with Code Size differences (18 improved, 8 regressed), 71 unchanged.

coreclr_tests.pmi.Linux.x64.checked.mch
Total bytes of delta: -8914
804 total files with Code Size differences (606 improved, 198 regressed), 2711 unchanged.

libraries.crossgen2.Linux.x64.checked.mch
Total bytes of delta: -10620
717 total files with Code Size differences (668 improved, 49 regressed), 2042 unchanged.

libraries.pmi.Linux.x64.checked.mch
Total bytes of delta: -8268
925 total files with Code Size differences (799 improved, 126 regressed), 622 unchanged.

libraries_tests.pmi.Linux.x64.checked.mch
Total bytes of delta: -21441
1991 total files with Code Size differences (1898 improved, 93 regressed), 1088 unchanged.

benchmarks.run.windows.arm64.checked.mch
Total bytes of delta: -112
46 total files with Code Size differences (41 improved, 5 regressed), 207 unchanged.

coreclr_tests.pmi.windows.arm64.checked.mch
Total bytes of delta: -19676
430 total files with Code Size differences (342 improved, 88 regressed), 5914 unchanged.

libraries.crossgen2.windows.arm64.checked.mch
Total bytes of delta: -63512
6167 total files with Code Size differences (6076 improved, 91 regressed), 3307 unchanged.

libraries.pmi.windows.arm64.checked.mch
Total bytes of delta: -20460
1132 total files with Code Size differences (1069 improved, 63 regressed), 7564 unchanged.

libraries_tests.pmi.windows.arm64.checked.mch
Total bytes of delta: -20180
2530 total files with Code Size differences (2386 improved, 144 regressed), 4099 unchanged.

benchmarks.run.windows.x86.checked.mch
Total bytes of delta: -189
28 total files with Code Size differences (17 improved, 11 regressed), 37 unchanged.

coreclr_tests.pmi.windows.x86.checked.mch
Total bytes of delta: -5880
716 total files with Code Size differences (497 improved, 219 regressed), 115 unchanged.

libraries.crossgen2.windows.x86.checked.mch
Total bytes of delta: -2369
301 total files with Code Size differences (257 improved, 44 regressed), 573 unchanged.

libraries.pmi.windows.x86.checked.mch
Total bytes of delta: -770
273 total files with Code Size differences (144 improved, 129 regressed), 153 unchanged.

libraries_tests.pmi.windows.x86.checked.mch
Total bytes of delta: -5537
1236 total files with Code Size differences (1092 improved, 144 regressed), 296 unchanged.

coreclr_tests.pmi.Linux.arm.checked.mch
Total bytes of delta: -1620
69 total files with Code Size differences (66 improved, 3 regressed), 109 unchanged.

libraries.crossgen2.Linux.arm.checked.mch
Total bytes of delta: -950
251 total files with Code Size differences (246 improved, 5 regressed), 47 unchanged.

libraries.pmi.Linux.arm.checked.mch
Total bytes of delta: -72
28 total files with Code Size differences (26 improved, 2 regressed), 18 unchanged.

libraries_tests.pmi.Linux.arm.checked.mch
Total bytes of delta: -38
12 total files with Code Size differences (12 improved, 0 regressed), 239 unchanged.

The regressions are small and expected, they are:

  1. noise from changing initFrameSize and saving/restoring non-vol regs;
  2. LSRA noise because now we have more candidates and sometimes do worse decisions;
  3. probably some minopts regressions because we don't do the optimization there, but I have not seen them in the diffs yet.

The ratio of improvements/regressions in benchmarks was concerning so I manually checked that all regressions are in one of the first 2 categories.

contributes to #43867

@sandreenko sandreenko added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization labels Jul 15, 2021
@sandreenko
Copy link
Contributor Author

/azp run runtime-coreclr jitstress, runtime-coreclr outerloop, runtime-coreclr jitstressregs

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@sandreenko
Copy link
Contributor Author

GitHub does not show the checks for me but they were started:

  1. runtime
  2. jitstressregs
  3. jitstress
  4. outerloop

@sandreenko
Copy link
Contributor Author

PTAL @dotnet/jit-contrib, I would like to sneak 1 more change into Prev7 if somebody has time to review this simple change.

It actually fixes a wrong usage of OptimizationEnabled() so maybe we can merge it in the next one as a correctness fix, but still would be safer to merge it in Prev7.

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

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

Great catch!

@kunalspathak
Copy link
Member

outerloop failures are related to #55657.

It was failing on DevDiv_280120 arm32 linux, did not repro with an altjit.
@sandreenko
Copy link
Contributor Author

I looked at the failures and most were unrelated but one was hitting the new assert that I added here. I have disabled the assert and will open an issue to check why it was failing on that test. The assert was about catching missed optimization opportunities, not about correctness so it is safe not to add it.

@sandreenko sandreenko merged commit 6d3bb36 into dotnet:main Jul 15, 2021
@sandreenko sandreenko mentioned this pull request Aug 2, 2021
10 tasks
@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2021
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 optimization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants