Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: grunwald@flute.cs.uiuc.edu Newsgroups: comp.sys.sun Subject: Re: libm in SunOS 4.0 Keywords: Software Message-ID: Date: 9 May 89 23:10:54 GMT References: <8904130100.AA14938@dgh.sun.com> Sender: usenet@rice.edu Organization: University of Illinois, Urbana-Champaign Lines: 26 Approved: Sun-Spots@rice.edu Original-Date: 3 May 89 15:09:17 GMT X-Sun-Spots-Digest: Volume 7, Issue 279, message 5 of 23 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@flute.cs.uiuc.edu