Skip to content

if-then-else changes in Cmmgen#430

Merged
mshinwell merged 4 commits intoocaml:trunkfrom
mshinwell:flambda_prereq-cmm_ifthenelse
Feb 5, 2016
Merged

if-then-else changes in Cmmgen#430
mshinwell merged 4 commits intoocaml:trunkfrom
mshinwell:flambda_prereq-cmm_ifthenelse

Conversation

@mshinwell
Copy link
Copy Markdown
Contributor

I'm going to leave @chambart to comment on this.

@mshinwell
Copy link
Copy Markdown
Contributor Author

(Marking as flambda-prerequisite until such time as @chambart may downgrade it. It needs removing from chambart/flambda_merge if that happens.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the only case where this matters with flambda is with loops when the first rounds is always runned

@alainfrisch
Copy link
Copy Markdown
Contributor

This looks correct to me. I'd still be interested in an example about the "for loop" unrolling requiring the simplification in if-then-else. I would have expected this optimization to be done at the flambda level.

@damiendoligez damiendoligez added this to the 4.03.0 milestone Jan 15, 2016
@chambart
Copy link
Copy Markdown
Contributor

Hum sorry I looked at it a bit more and mixed something in my example.
In fact, the places where constant branch where not eliminated by flambda before, is when exit_if_false or exit_if_true is involved on code generated by transforming a sequand or sequor.

A more general transformation handling branches will be done at some point in flambda, but not in this release, and this small change allow to simply avoid some bad cases.

By the way, I'm still not completely convinced that the recursive cases in test_bool
(below let and if_then_else) are beneficial. That allows to improve some cases, but might
prevent the generation of efficient test sequence for the if (handled by selectgen), since the
test does not appear right below the if.

By the way, there is no loop (for, while) unrolling at all in flambda.

@chambart
Copy link
Copy Markdown
Contributor

This is useful, but I wouldn't consider that a prerequisite, hence I removed the tag.

@damiendoligez
Copy link
Copy Markdown
Member

OK for merging.

@alainfrisch
Copy link
Copy Markdown
Contributor

@damiendoligez : @chambart himself does not seem completely sure that this proposal cannot degrade some cases. Shouldn't we apply some care before merging?

@mshinwell
Copy link
Copy Markdown
Contributor Author

If we're worried about this, maybe what we should do is wait until a quiet time (maybe at a weekend) and then merge this. OCamlPro's benchmark suite should be able to detect any noticeable regressions.

@damiendoligez
Copy link
Copy Markdown
Member

OK for merging after getting some evidence that it doesn't degrade performance, or after removing the recursive cases.

Or, @chambart what do you think of postponing to 4.04?

@chambart
Copy link
Copy Markdown
Contributor

It is not on my repository, so I can't change it, but I would be in favor of taking the obviously beneficial case and wait for 4.04 to have some time to test and think about the rest.

@mshinwell
Copy link
Copy Markdown
Contributor Author

@chambart Just make a new pull request that reverts the bit you want to keep back...

@damiendoligez
Copy link
Copy Markdown
Member

I'll re-approved when the changes are made.

@mshinwell
Copy link
Copy Markdown
Contributor Author

@chambart Please confirm the diff now looks correct (I merged your PR on my repo and fixed a conflict).

@damiendoligez Please approve.

@mshinwell
Copy link
Copy Markdown
Contributor Author

@chambart Just waiting for your approval too

@chambart
Copy link
Copy Markdown
Contributor

chambart commented Feb 5, 2016

This looks ok now.

mshinwell added a commit that referenced this pull request Feb 5, 2016
@mshinwell mshinwell merged commit f22ead0 into ocaml:trunk Feb 5, 2016
EduardoRFS pushed a commit to EduardoRFS/ocaml that referenced this pull request Dec 6, 2020
Add a test to exercise stored continuations and the garbage collector
chambart pushed a commit to chambart/ocaml-1 that referenced this pull request Jan 4, 2022
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
Co-authored-by: tmattio <tmattio@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants