Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!wesommer From: wesommer@athena.mit.edu (William E. Sommerfeld) Newsgroups: comp.lang.c Subject: Re: inline assembly? Message-ID: <3585@bloom-beacon.MIT.EDU> Date: 9 Mar 88 04:55:18 GMT References: <11702@brl-adm.ARPA> <243@eagle_snax.UUCP> <2245@geac.UUCP> <703@l.cc.purdue.edu> <10573@mimsy.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: wesommer@athena.mit.edu (William E. Sommerfeld) Organization: Massachusetts Institute of Technology Lines: 33 In article <10573@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >(The portable fix for the problem, of course, is to tweak the compiler >so that it generates nearly-optimal code. This also has a much bigger >potential payoff. Inline assembly is merely a band-aid.) I second that motion. The original MIT/Athena implementation of DES (for our Kerberos authentication system) was extensively hand-tweaked, with some VAX-specific inline assembly, by Steve Miller. [1] I spent some time looking at what he did; the bulk of his tweaks involved replacing `extzv' (a bitfield extract, generated because the VAX doesn't believe in unsigned shifts) with `rotl' (rotate) when it was preceded by or followed by a `bicl' with a constant (bit clear); this produced about a 10-20% improvement on the MicroVAX II. It was relatively trivial to add a pair of peephole optimization patterns to Stallman's GNU C compiler to cause it to do just what Steve Miller did. \begin{gcc plug} GCC seems to be extremely portable and very easy to tweak to produce better code. If a few more ports get done, the excuse "but the compiler produces bad code" will probably not be acceptable any more. \end{gcc plug} - Bill [1] The assembly was put in `#ifdef VAXASM' so it was possible to compile a version on the VAX which ran just the straight C code. For those people who get our DES library but don't have GCC, we'll include the VAX assembler for the version compiled with GCC.