-
Notifications
You must be signed in to change notification settings - Fork 57
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 specialization optimization #2944
Conversation
fe97d3b
to
7b938d9
Compare
1fe86ad
to
fcd64b8
Compare
db472c2
to
833ef24
Compare
833ef24
to
7f3fbfb
Compare
@@ -269,7 +271,7 @@ convertNode = dmapLRM go | |||
|
|||
shiftSpecargs :: [Int] -> [Int] -> [Int] | |||
shiftSpecargs specargs = | |||
map (\argNum -> argNum - length (filter (argNum <) specargs)) | |||
map (\argNum -> argNum - length (filter (argNum >) specargs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the change from <
-> >
fix a bug or is it related to another change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was incorrect, but we didn't see it because:
- This adjusts the indices of arguments marked for specialization which are not specialized because the provided argument has the wrong form, e.g., it is a variable (makes no sense to specialize by an unknown). They can be specialized later in another iteration if, e.g., inlining substitutes a concrete value for the variable, but this is not very common.
- If specialization fails nothing really bad happens -- the function application is just not specialized and thus less efficient.
@@ -19,7 +19,7 @@ optimize' :: CoreOptions -> Module -> Module | |||
optimize' opts@CoreOptions {..} md = | |||
filterUnreachable | |||
. compose | |||
(4 * _optOptimizationLevel) | |||
(6 * _optOptimizationLevel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this changed from 4 to 6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because with maps and folds inside record definitions 4 iterations are not enough to inline & specialize everything in a typical case (without further nestings).
d5f4a76
to
e396a01
Compare
* Closes #121 * Depends on anoma/juvix#2944 * Includes #123 * Adds `Stdlib.Data.Range` to the Prelude. Since now `for` and `rfor` are trait fields, there is no name clash anymore. --------- Co-authored-by: Paul Cadman <git@paulcadman.dev>
Checklist