std.mixins
bearophile
bearophileHUGS at lycos.com
Tue Aug 31 13:11:28 PDT 2010
dsimcha:
> I thought about this. Simple loop unrolling doesn't seem like a very useful
> optimization on modern hardware because branch prediction and pipelining have
> gotten so good. It can still be useful if you also change the loop body a little,
> for example using multiple accumulators to increase instruction level parallelism,
> but this is hard to write generically. I can't think of a way to write such a
> mixin such that it would be both generic and useful.
Today loop unrolling is still a basic tool for optimization. Dynamic loop unrolling is one of the most important optimizations done today by the Sun JavaVM.
My best code for loop unrolling is inside bug 4085, but as I have explained there I think it's not a good idea to add it to Phobos. It's better to add even a very minimal version of static foreach in the language (despite what Andrej Mitrovic has recently said).
Bye,
bearophile
More information about the Digitalmars-d
mailing list