<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Thank you for the pointers and some insights.</div><div id="AppleMailSignature">I noticed that unroll directive was needed for this case. Actually size, effort and unroll was needed to get the desired effect.</div><div id="AppleMailSignature">I have been nagging about this before. Some effort should be made to do these optimizations automatically, they can be really hard to do manually, also consider how "funny" the code would look if you unroll the code your self ;-)<br><br>/Tony<br>"typed while walking!"</div><div><br>On 12 Nov 2016, at 10:53, Richard Carlsson <<a href="mailto:carlsson.richard@gmail.com">carlsson.richard@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div>New as of 2001 or so. :-) Inlining is documented towards the bottom of this page: <a href="http://erlang.org/doc/man/compile.html">http://erlang.org/doc/man/compile.html</a><br></div><br>However, it only describes the inline_size option. There is also the inline_effort limit, which can be increased from the default 150 at the expense of compile time (its purpose is to ensure that the automatic inliner does not get bogged down in any particular part of the code). And then there's the slightly experimental inline_unroll, which is actually more of a side effect of the normal inlining behaviour if you just allow it to repeat itself on loops.<br><br>The interaction between the unroll limit and the size/effort limit is not obvious (and could maybe be improved - I haven't looked at that code for 15 years). In particular, the size limit seems to need bumping from the default 24 to about 200 or more for unrolling to happen, depending on the size of the loop body, and the effort limit also needs raising to at least 500 or 1000. I suggest you use the 'to_core' option and inspect the result until you find settings that work for your program. If you want to use unrolling you should probably put that code in a separate module and use custom compiler option for that module, not apply the same limits to your whole code base.<br><br></div>See comments in <a href="https://github.com/erlang/otp/blob/maint/lib/compiler/src/cerl_inline.erl">https://github.com/erlang/otp/blob/maint/lib/compiler/src/cerl_inline.erl</a> for details. (It's a wonderful algorithm, if you're into that sort of thing, but can take a while to get your head around. It's basically just constant propagation and folding, treating functions like any other constants, and handling local functions and funs in the same way. I'd revisit it if I had the time.)<br><div><br>Note that if you use the option <span class="gmail-code">{inline,[{Name,Arity},...]} instead of just 'inline', then an older, simpler inliner is used, which _only_ inlines those functions you listed, ignoring any size limits.<br></span></div><div class="gmail_extra"><br><div><div class="gmail_signature" data-smartmail="gmail_signature">        /Richard</div></div>
<br><div class="gmail_quote">2016-11-12 6:56 GMT+01:00 Sergej Jurečko <span dir="ltr"><<a href="mailto:sergej.jurecko@gmail.com" target="_blank">sergej.jurecko@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><p dir="ltr">On Nov 11, 2016 6:40 PM, "Tony Rogvall" <<a href="mailto:tony@rogvall.se" target="_blank">tony@rogvall.se</a>> wrote:</p>
<p dir="ltr">> I used this ( WARNING! not to be used in production code yet, I guess? )</p>
</span><p dir="ltr">Are these flags new? </p><span class="HOEnZb"><font color="#888888">
<p dir="ltr">Sergej</p>
</font></span></blockquote></div><br></div></div>
</div></blockquote></body></html>