<div class="gmail_quote">On 17 January 2012 05:55, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Walter:<br>
<div class="im"><br>
> But don't worry, I'm not planning on working on that at the moment :-)<br>
<br>
</div>Until better optimizations are implemented, I see a "simple" optimization for vector ops. When the compiler knows an arrays are very small it unrolls the operation in-place:<br>
<br>
int n = 5;<br>
auto a = new int[n];<br>
auto b = new int[n];<br>
a[] += b[];<br>
<br>
==><br>
<br>
int n = 5;<br>
auto a = new int[n]; // a and b are dynamic arrays,<br>
auto b = new int[n]; // but their length is easy to find at compile-time<br>
a[0] += b[0];<br>
a[1] += b[1];<br>
a[2] += b[2];<br>
a[3] += b[4];<br>
a[5] += b[5];<br></blockquote><div><br></div><div>If this doesn't already exist, I think it's quite important. I was thinking about needing to repeatedly specialise a template last night for a bunch of short lengths of arrays, for this exact reason.</div>
<div>Unrolling short loops must be one of the most trivial and worthwhile optimisations...</div></div>