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

Support devirtualizing/inlining Comparer<T>.Default.Compare #47343

Closed
stephentoub opened this issue Jan 22, 2021 · 2 comments
Closed

Support devirtualizing/inlining Comparer<T>.Default.Compare #47343

stephentoub opened this issue Jan 22, 2021 · 2 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Comments

@stephentoub
Copy link
Member

dotnet/coreclr#14125 made EqualityComparer<T>.Default an intrinsic recognized by the JIT, teaching the JIT what concrete type of comparer would be used for any given T and enabling EqualityComparer<T>.Default.Equals to be fully devirtualized and inlined. This in turn led to optimizations in managed code, where code that was making heavy use of EqualityComparer<T>.Default as a default implementation added specialized code paths that used EqualityComparer<T>.Default, e.g. in various collections like Dictionary<>.

Comparer<T>.Default could benefit from similar optimizations. Comparer<T>.Default.Compare doesn't show up quite as much as EqualityComparer<T>.Default.Equals, but it still shows up in a lot of places, and there are a variety of collections (e.g. the new PriorityQueue<> being added in .NET 6) that would similarly optimize for Comparer<T>.Default if Comparer<T>.Default.Compare could be devirtualized and inlined.

Is this feasible?

cc: @AndyAyersMS, @eiriktsarpalis

@stephentoub stephentoub added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 22, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jan 22, 2021
@stephentoub
Copy link
Member Author

Just found another issue for this, so closing as a dup of #39873.

@AndyAyersMS
Copy link
Member

Should be feasible, yes. Will leave further discussion to the linked issue.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 21, 2021
@JulieLeeMSFT JulieLeeMSFT added duplicate and removed untriaged New issue has not been triaged by the area owner labels Apr 13, 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

No branches or pull requests

3 participants