libm in SunOS 4.0

grunwald at flute.cs.uiuc.edu grunwald at flute.cs.uiuc.edu
Wed May 10 09:10:54 AEST 1989


I would like to point out that with Gnu C 1.35, using the 68881 version of
math.h with inlined math functions, Gnu C produces exactly the same code
that David Hugh posted, modulo label names.

An example inline specification for Gnu C is:

__inline static const double sin (double x)
{
  double value;
  __asm ("fsin%.x %1,%0" : "=f" (value) : "f" (x));
  return value;
}

which has similar advantages to the .il template method mentioned;
however, it has further advantages, similar to the ones mentioned for
FORTRAN. Most notably, CSE and code hoisting can move the function out of
loops, although I imagine this would rarely occur for math functions.
There are other advantages of combining inline & smarter asm() notation :
you can inline other time-critical functions (e.g. spl(), spinlock loops,
etc).


--
Dirk Grunwald
Univ. of Illinois
grunwald at flute.cs.uiuc.edu



More information about the Comp.sys.sun mailing list