Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site decwrl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!dec-rhea!dec-jon!moroney From: moroney@jon.DEC (Mike Moroney) Newsgroups: net.lang.c Subject: Re: String Copy idiom Message-ID: <1061@decwrl.UUCP> Date: Mon, 11-Mar-85 18:00:58 EST Article-I.D.: decwrl.1061 Posted: Mon Mar 11 18:00:58 1985 Date-Received: Wed, 13-Mar-85 00:57:37 EST Sender: daemon@decwrl.UUCP Organization: DEC Engineering Network Lines: 55 I think this is cute, how VAX/VMS beats Unix at its own game. The VMS C compiler generates code as good as or better than anything I have seen posted so far! char *s,*t; while (*s++ = *t++); generates (on a VAX 780): movb (r2)+,(r1)+ beql sym.2 sym.1: movb (r2)+,(r1)+ bneq sym.1 sym.2: This is as fast as you can get. char *s,*t; while ((*s = *t) != '\0') { s++; t++; } generates: movb (r2),(r1) beql sym.4 sym.3: incl r1 incl r2 movb (r2),(r1) bneq sym.3 sym.4: The default settings of the C compiler were used (that is I didn't select any "generate warp speed code" flags). Notice I did NOT use "register char *" since VAX C is at least as intelligent as you are when it decides what should or should not go into registers. In fact version 1 of the C compiler ignored "register" definitions for that reason. They put it back in V2.0 to appease those who think they are smarter than the compiler (which treats it as a "hint"). I have also seen a benchmark program where the identical C program was compiled and run on identical VAX hardware, one running Unix, and one running VMS. The Unix program took 3 times as long to run as the VMS. This program (which did all integer arithmetic) used static variables, so it didn't even have the benefit of automatically placing auto's in registers when possible. I would think Unix, being 95% written in C, would at least have a d@mn good C compiler. Want to improve the throughput of your Unix system? Recompile it in VAX/VMS C! These are not the views of Digital, although I am sure Digital agrees with me. Mike Moroney ..!decwrl!rhea!jon!moroney