inline assembly?

William E. Sommerfeld wesommer at athena.mit.edu
Wed Mar 9 14:55:18 AEST 1988


In article <10573 at mimsy.UUCP> chris at 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.



More information about the Comp.lang.c mailing list