dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.9k stars 4.63k forks source link

Improve JIT loop optimizations (.NET 9) #93144

Closed BruceForstall closed 1 month ago

BruceForstall commented 11 months ago

We plan to continue improving JIT optimization capabilities for loop code. An overview of many JIT optimization possibilities is here; this issue will focus on issues we choose to address in .NET 9.

Planned for .NET 9

Loop recognition and canonicalization

Loop cloning

Induction variables

Pushed out of .NET 9

Loop cloning

Multi-dimensional array improvements

Loop peeling

ghost commented 11 months ago

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

Issue Details
We plan to continue improving JIT optimization capabilities for loop code. An overview of many JIT optimization possibilities is [here](https://github.com/dotnet/runtime/issues/65342); this issue will focus on issues we choose to address in .NET 9. # Planned for .NET 9 ## Loop recognition and canonicalization - [ ] https://github.com/dotnet/runtime/issues/43713 Describes two cases where loops are missed due to various issues. - [ ] https://github.com/dotnet/runtime/issues/58941 F# loops not recognized ## Loop cloning - [ ] https://github.com/dotnet/runtime/issues/82946 Support loop cloning for Span - [ ] https://github.com/dotnet/runtime/issues/77071 Support loop cloning of class member arrays - [ ] https://github.com/dotnet/runtime/issues/85552 Support loop cloning with non-int iteration variables - [ ] https://github.com/dotnet/runtime/issues/62615 Consider rebuilding loop table after loop cloning ## Multi-dimensional array improvements - [ ] https://github.com/dotnet/runtime/issues/71674 RyuJIT: support cloning loop nests with multi-dimensional array accesses - [ ] https://github.com/dotnet/runtime/issues/71676 Improve hoisting, CSE, LSRA for MD array accesses ## Loop peeling - [ ] https://github.com/dotnet/runtime/issues/93142 Implement loop peeling ## Induction variables - [ ] https://github.com/dotnet/runtime/issues/7312 RyuJIT: Index Variable Widening optimization for array accesses - [ ] https://github.com/dotnet/runtime/issues/93143 RyuJIT: Implement induction variable analysis
Author: BruceForstall
Assignees: -
Labels: `area-CodeGen-coreclr`, `User Story`
Milestone: 9.0.0
jakobbotsch commented 8 months ago

With recent work we are close to having moved from the old lexical representation of loops to a more general graph-based one. Since I'll be out until New Year's, here's a more detailed list of work done and expected future work.

Some stats from the loop representation switch over some of our win-x64 collections:

JulieLeeMSFT commented 1 month ago

.NET9 work is complete. Closing.

JulieLeeMSFT commented 1 month ago

Will move the pushed-out items to .NET 10 user story during .NET 10 planning.