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

Use correct assignedInterval for SPILL_COST calculation #55247

Merged
merged 1 commit into from
Jul 8, 2021

Conversation

kunalspathak
Copy link
Member

@kunalspathak kunalspathak commented Jul 7, 2021

In #53853, I changed the SPILL_COST heuristic to also consider reload weight if the variable will be reloaded in future location rather than getting spilled at past location. However, while doing that, I incorrectly checking the wrong interval for isLocalVar. I wanted to use similar condition as used in

if (fromRefPosition->RegOptional() && !(interval->isLocalVar && fromRefPosition->IsActualRef()))

However, the interval I was using was that of the current refposition for which we are allocating the register rather than the interval to which the candidate register is already assigned.

Here is the sample diff of Algorithms.VectorDoubleRenderer:RenderSingleThreadedWithADT(float,float,float,float,float) that we can see: The high weight local variable gets assigned to the register.

image

With better selection of register, we can now eliminate unnecessary spilling/resolution of expensive variables:

image

Some of the other regressions seen will be fixed by #54345.

Fixes: #54352

@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 Jul 7, 2021
@kunalspathak
Copy link
Member Author

Code Size

Scenario OS/arch main PR Diff Diff %
Benchmarks Linux.x64 106830 106996 166 0.16%
Benchmarks windows.x64 79433 79432 -1 0.00%
Benchmarks windows.x86 213690 214110 420 0.20%
Libraries.crossgen2 Linux.x64 56998 57020 22 0.04%
Libraries.crossgen2 windows.x64 6972 6865 -107 -1.53%
Libraries.crossgen2 windows.x86 240319 240312 -7 0.00%
Libraries.pmi Linux.x64 82219 82134 -85 -0.10%
Libraries.pmi windows.x64 73971 74381 410 0.55%
Libraries.pmi windows.x86 410698 411263 565 0.14%

Perf Score

OS/arch main PR Diff Diff %
Linux.x64 102397 100669.68 -1727.32 -1.69%
windows.x64 168025.98 164684.59 -3341.39 -1.99%
windows.x86 10261610.27 10258036.27 -3574 -0.03%
Linux.x64 107910.52 106060.97 -1849.55 -1.71%
windows.x64 26584.66 26107 -477.66 -1.80%
windows.x86 535206.26 535575.34 369.08 0.07%
Linux.x64 708552.68 706913.69 -1638.99 -0.23%
windows.x64 128077.33 126861.96 -1215.37 -0.95%
windows.x86 41500664980 40594662922 -906002058.5 -2.18%

Detail diffs are: https://gist.github.com/kunalspathak/49940d4690ef99f2e24b2ee8bfbac9e2

@kunalspathak kunalspathak marked this pull request as ready for review July 7, 2021 21:25
@kunalspathak kunalspathak changed the title fix spill cost calculation Use correct assignedInterval for SPILL_COST calculation Jul 7, 2021
@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

@kunalspathak
Copy link
Member Author

Failures seems to be infra issues.

@kunalspathak kunalspathak merged commit 7f88911 into dotnet:main Jul 8, 2021
@sandreenko sandreenko mentioned this pull request Jul 8, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 7, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regressions from using reloadWeight when evaluating spill cost
3 participants