-
Notifications
You must be signed in to change notification settings - Fork 5
Case-of-known-constructor through a let-bound scrutinee (#214) #216
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
changelog.d/20260709_114305_unisay_known_ctor_through_let.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ### Added | ||
|
|
||
| - Case-of-known-constructor through a let-bound scrutinee in the IR optimizer | ||
| (#214). When a `Standalone` Let binding's RHS is a saturated constructor | ||
| application and the binder is read only through constructor-eliminating reads, | ||
| the reads fold: `ReflectCtor v` becomes the tag string, and each field read | ||
| (`ObjectProp v "valueᵢ"`, `DataArgumentByIndex i v`) becomes a fresh | ||
| field-binder bound once to the iᵗʰ argument — GHC's case-binder to | ||
| field-binder split, so a non-trivial argument read at several sites is | ||
| evaluated once, not duplicated. The binding is then dropped, its unread | ||
| arguments discarded with the same licence `reduceKnownConstructor` drops a | ||
| field read's siblings. Trivial and dead field-binders inline or DCE away, and | ||
| the folded reads let the surrounding `Eq` / `if` collapse to its live arm, | ||
| reaching the case-of-known-constructor payoff of #177 through a Let. This | ||
| extends the in-place fold to the multiply-read scrutinee that beta reduction | ||
| Let-binds — the shape a dictionary method's several scrutinee reads produce — | ||
| so it is the enabler that makes dictionary-method inlining (#180) pay off. The | ||
| rule declines when the binder is read as a whole value, which dropping it | ||
| would dangle and keeping it would duplicate the arguments. Standalone impact | ||
| is near zero: the shape only shows up once #180 inlines a dictionary method, | ||
| so on its own this pass leaves generated code essentially unchanged. |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.