On 17 January 2012 05:55, bearophile <bearophileh...@lycos.com> wrote:
> Walter: > > > But don't worry, I'm not planning on working on that at the moment :-) > > 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: > > int n = 5; > auto a = new int[n]; > auto b = new int[n]; > a[] += b[]; > > ==> > > int n = 5; > auto a = new int[n]; // a and b are dynamic arrays, > auto b = new int[n]; // but their length is easy to find at compile-time > a[0] += b[0]; > a[1] += b[1]; > a[2] += b[2]; > a[3] += b[4]; > a[5] += b[5]; > 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. Unrolling short loops must be one of the most trivial and worthwhile optimisations...