3 ms·
> why did Duff choose "8" as the magic number? My rule of thumb when unrolling loops in assembly was to only unroll up to and including the bit length of the m
by xirium 18y ago
> why did Duff choose "8" as the magic number?
My rule of thumb when unrolling loops in assembly was to only unroll up to and including the bit length of the machine. So, on eight bit hardware, I would only unroll loops of eight iterations or less.
- aston 18y agoFrom the man himself (http://www.lysator.liu.se/c/duffs-device.html http://www.lysator.liu.se/c/duffs-device.html): "Transformations like this can only be justified by measuring the resulting code. Be careful when you use this thing that you don't unwind the loop so much that you overflow your machine's instruction cache. Don't try to be smarter than an over-clever C compiler that recognizes loops that implement block move or block clear and compiles them into machine idioms."
- xirium 18y ago> Be careful when you use this thing that you don't unwind the loop so much that you overflow your machine's instruction cache. I considered this case shortly after posting. Specifically, my rule of thumb fails miserably on the 68020 which has a very small instruction cache.