|Anonymous | Login | Signup for a new account||2014-08-20 08:51 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005346||OCaml||OCaml general||public||2011-08-21 09:20||2014-07-16 20:50|
|Target Version||after-4.02.0||Fixed in Version|
|Summary||0005346: Improve Cmm code generator for "for" loops.|
|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.
|Attached Files||0001-Improve-Cmm-code-generator-for-for-loops.patch [^] (3,146 bytes) 2011-08-21 09:20 [Show Content]|
First of all, thanks for the patch. Disclaimer: I'm in no way an expert of Cmm. Here are some preliminary remarks, though.
- Your patch adds complexity for what seem to be little benefit. The test is an initial one, it's not in the loop. You're just skipping a couple instructions. Is it worth the extra complexity of your approach? Can you justify better why we should make that case harder to understand in cmmgen?
- There are no comments in your patch, which resonates with the point above. Moreover, the current version has an id_prev identifier defined. While I fail to see why it's there in the first place (your version of the test seems both shorter and correct), I'd appreciate if you could share your thoughts on this.
Thinking about performance, even in the case of nested loops, say
for i = 0 to n; do
for j = 0 to i; 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.
|Not urgent enough for 4.01.|
|2011-08-21 09:20||meurer||New Issue|
|2011-08-21 09:20||meurer||File Added: 0001-Improve-Cmm-code-generator-for-for-loops.patch|
|2011-12-16 18:02||protz||Note Added: 0006330|
|2011-12-21 14:23||gasche||Status||new => feedback|
|2012-09-06 16:43||doligez||Target Version||=> 4.00.1+dev|
|2012-09-20 16:27||doligez||Target Version||4.00.1+dev => 4.01.0+dev|
|2013-07-19 11:43||xleroy||Note Added: 0009812|
|2013-07-19 11:43||xleroy||Target Version||4.01.0+dev => 4.01.1+dev|
|2013-10-09 14:15||doligez||Tag Attached: patch|
|2014-05-25 20:20||doligez||Target Version||4.01.1+dev => 4.02.0+dev|
|2014-07-16 20:50||doligez||Target Version||4.02.0+dev => after-4.02.0|
|Copyright © 2000 - 2011 MantisBT Group|