-
Notifications
You must be signed in to change notification settings - Fork 53
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 generated code for derived instances #3189
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
lukaszcz
commented
Nov 22, 2024
•
edited
Loading
edited
- Closes Improve the inlining optimization to handle derived instances well #3186
- Changes the generated code for derived Eq instances to define a local recursive function with a let instead of a lambda. This is necessary, because otherwise an indirection is generated on each recursive call -- instance resolution inserts the instance identifier, which then is matched on and the function for the recursive call extracted instead of being called directly. This cannot be (easily) optimized in Core because, to avoid looping in the compiler, in general one cannot do inlining of recursive functions.
- Minor improvements to the inlining optimization and the main optimization phase: do inlining before specialization and more liberal rules for heuristic case value inlining.
lukaszcz
force-pushed
the
better-inline-case
branch
3 times, most recently
from
November 25, 2024 13:38
4992e43
to
d4305a7
Compare
Merged
lukaszcz
force-pushed
the
better-inline-case
branch
from
November 25, 2024 17:38
d4305a7
to
2cec4a3
Compare
I've used the code below to benchmark the potential gains of replacing the lambda with a recursive function defined in a let. I've used the main branch (f916c0a) to benchmark this, so the changes in the inlining phase implemented in this pr do not affect this.
I've used the native backend.
I've run
|
janmasrovira
approved these changes
Nov 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.