Looking for more library optimization patterns

bearophile bearophileHUGS at lycos.com
Sat Feb 15 14:49:51 PST 2014


Ivan Kazmenko:

> For short loops, an unrolled version like
>     a[0] += b[0];
>     a[1] += b[1];
>     a[2] += b[2];
> may well be faster than a simple loop as the following one:
>     foreach (immutable i; 0..3) {
>         a[i] += b[i];
>     }
> At least on x86/64.

Yes, but ldc is plenty able to unroll small loops with length 
known at compile time.

Bye,
bearophile


More information about the digitalmars-d-ldc mailing list