<div class="gmail_quote">On 17 January 2012 11:48, Martin Nowak <span dir="ltr"><<a href="mailto:dawg@dawgfoto.de" target="_blank">dawg@dawgfoto.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>On Tue, 17 Jan 2012 09:20:43 +0100, Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 17 January 2012 05:55, bearophile <<a href="mailto:bearophileHUGS@lycos.com" target="_blank">bearophileHUGS@lycos.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Walter:<br>
<br>
> But don't worry, I'm not planning on working on that at the moment :-)<br>
<br>
Until better optimizations are implemented, I see a "simple" optimization<br>
for vector ops. When the compiler knows an arrays are very small it unrolls<br>
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>
<br>
</blockquote>
<br>
If this doesn't already exist, I think it's quite important. I was thinking<br>
about needing to repeatedly specialise a template last night for a bunch of<br>
short lengths of arrays, for this exact reason.<br>
Unrolling short loops must be one of the most trivial and worthwhile<br>
optimisations...<br>
</blockquote>
<br></div></div>
If the compiler knows it's a compile time constant<br>
thus you could use a static foreach.<br>
</blockquote></div><br><div>Great idea! :)</div>