Mail Archives: djgpp/1997/03/04/01:05:40
On 3 Mar 1997 22:37:07 GMT Jeff Weeks <pweeks AT execulink DOT com> writes:
>All this talk about unrolling loop and I feel like an idiot :) What
>exactly is invovled in the process of unrolling loops?
Say you have:
for (i=0;i<4;i++)
{a;}
Then you would do:
a;
a;
a;
a;
This has several advantages:
Fewer branches;
Fewer additions (i never gets incremented, important in loops under 20
cycles per iteration);
Fewer compares (see above);
I've been able to unroll loops 64 times and fit them into about 1k -
however, more than 16 iterations usually doesn't help any more (the
overhead from taking care of the ends (since it rarely is a multiple of
64 iterations) just slows it down too much).
Don't bother unless you get down to nitty-gritty assembly optimizing,
though.
...Chambers
- Raw text -