News for hackers. Stuff that matters.
Re:How Duff's Device Works by gojomo on Friday November 12, 2010 @03:32AM (#1896983)
Fewer tests for the end-condition, and fewer jumps back to the start of the loop -- by a factor N, how many consecutive steps are 'unrolled'. (In these examples, N is 8 -- but it could be larger.)

But what if the number of steps isn't evenly divisible by N? That's where Duff's Device comes in; it lets one 'switch' at the beginning enter the loop at just the right place for the right number of remainder steps to be added to full iterations.

See also the Wikipedia article:

http://en.wikipedia.org/wiki/Duff%27s_device#Performance

There are no comments on this comment yet.