Closed
Conversation
That allows in such function to use only registers in the case `x<y` : ```ocaml let fun_l (x:int) y z = let r = if x < y then y else max x y in r + x + y ```
Member
|
For benchmarks you may want to try operf-macro (macro benchmarks) and operf-micro (micro benchmarks). |
Closed
Contributor
Contributor
|
No response from the author for more than a year, so closing. In general for pull requests proposing optimizations it would be helpful if benchmark numbers could be provided from the beginning. This is especially the case for ones like this where the benefit is unclear. @bobot If you have further time to work on it then please provide a branch against the latest released OCaml (currently 4.05) and ping either myself or @AltGr so we can add it to the benchmarking framework. |
stedolan
added a commit
to stedolan/ocaml
that referenced
this pull request
Feb 20, 2020
…l#180) It was only used to adjust the stack in caml_raise_exception, but that function immediately calls SWITCH_C_TO_OCAML, which resets the stack pointer.
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
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.
During the discussion of #162, it appears that a call in one branch will always hindered a fast path in another branch because all the live registers will have to be reloaded after the join point. The problem is particularly patent in ocaml since there is no callee saved registers.
This request for comment implements the analogous of this existing optimisation1. Instead of pushing later spillings in the branch that needs them, it pushes earlier reloadings in the branch that destroys the registers.
With this optimization the following (dumb) function use only registers in the case
x<y, and as many spilling/reloading than previously :Deadcode elimination pass is added after the split pass because unneeded reloading can be added as in this function:
This optimization has similar bad cases than the previous one and the interaction with the previous one (spill late) could add a lot of spilling. In this function (where fun_l is automatically inlined) x is spilled once more (in the slow path) by call to
fun_l:If the previous optimization (spill late) is deactivated there are as many spilling/reloading as before.
Does this optimization have already been considered? Do you think it can be interesting to investigate it more? with macro-benchmarks?
Regards,