In article <cl**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
(Fear not, I have no intention of actually using it!)
Was there a particular reason Duff chose to unroll the loop 8 times,
as opposed to some other number of times (besides some reason having
to do with the original application of the device)?
A power of two would make the math that's left for the compiler to do
simpler (it can be done entirely with bitwise operators rather than
having to do arithmetic).
Other than style or application-specific reasons, I don't see why 8
would be inherently a better or worse choice than any other power of two,
except possibly that it's a sweet spot wrt the law of diminishing returns
(less unrolling gives less improvement, more unrolling doesn't get enough
extra improvement to be worth the extra typing).
dave
--
Dave Vandervies
dj******@csclub.uwaterloo.ca
Much as we might regret it sometimes, comp.lang.c is not actually
normative.
--Richard Heathfield in comp.lang.c