MS/CW-style inline assembly for GCC

Ian Lance Taylor ian@wasabisystems.com
Mon May 10 16:43:00 GMT 2004


Jack Lloyd <lloyd@randombit.net> writes:

> Actually pretty much all MPI math can be implemented efficiently in plain
> C.

Is this really true?  What about the simple case of unlimited-
precision addition on a processor which has a carry flag?  Do we
expect the compiler to be smart enough to turn a loop like
  c = 0;
  for (i = 0; i < len; i++)
    {
      r[i] = a[i] + b[i] + c;
      c = (int) (((long long) a[i] + (long long) b[i]) >> 32);
    }
into code which uses the "add with carry" instruction?

Sure, there is no algorithmic advantage.  But the code in assembler
will be at least twice as fast.

Ian



More information about the Gcc mailing list