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 Cmm code generator for "for" loops. #5346
Comments
Comment author: @protz Hi, First of all, thanks for the patch. Disclaimer: I'm in no way an expert of Cmm. Here are some preliminary remarks, though.
Thinking about performance, even in the case of nested loops, say for i = 0 to n; do then the extra test that might have been run n+1 times wouldn't be skipped since j is not a constant expression. This seems to me like a very ad-hoc optimization that adds extra complexity for close to zero benefit. I'd like to be proved wrong, though :) so please let me know why you think this optimization has to be included. A benchmark on some real-world code may help me see better why you want this. Cheers, jonathan |
Comment author: @xavierleroy Not urgent enough for 4.01. |
Comment author: @xavierleroy No activity on this PR in the last 4 years. Should we keep it alive or suspend it? |
Comment author: @mshinwell We have some vague plans for local CPS constructs in flambda in the future; I wouldn't be surprised, having expressed these looping constructions like that, if things such as this PR just fall out in the wash. So I would vote for closing this. |
Comment author: @mshinwell CPS-flambda should sort this out. Closing |
Original bug ID: 5346
Reporter: meurer
Status: closed (set by @mshinwell on 2016-12-07T12:57:02Z)
Resolution: not a bug
Priority: normal
Severity: tweak
Version: 3.12.1
Target version: later
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Monitored by: meyer @protz @ygrek @hcarty @alainfrisch
Bug description
The code generated by cmmgen for Ufor loops doesn't optimize in case of constant low and high expressions. This is fixed by a special case where the initial comparison can be skipped in case of constant low and high subexpressions.
In addition, this patch also reorders the generated code by moving the initial comparison out of the catch block in the general case. This may enable certain optimizations in later phases.
File attachments
The text was updated successfully, but these errors were encountered: