Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: faster bcopy using duffs device Keywords: loop unrolling, optimize, hacks Message-ID: <14558@haddock.ima.isc.com> Date: 8 Sep 89 20:45:42 GMT References: <5180@portia.Stanford.EDU> <19473@mimsy.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 13 In article <19473@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >bcopy() should be written in assembly (on most processors), put in >a library, and forgotten about... Yes. (And it should be called memcpy(), that being the standard name; of course bcopy() can be an alternate synonym if it's done properly.) But if you really want to blow the socks off the benchmarks, you should have the compiler recognize memcpy() as a builtin. This not only allows it to be inlined, but also makes possible certain compile-time optimizations such as constant length move (for which unrolling might be a win) and known-alignment pointers (for which it could safely copy larger-sized chunks). Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint